Nuxt.js: How to add jQuery plugis?

Created on 14 Sep 2020  路  3Comments  路  Source: nuxt/nuxt.js

Already tried making it work,

making a custom javascript that has moment and jquery and requiring also the jquery plugin,
but it still not working, though then I wrap the plugin with

(function ($) {
}(jQuery))

it works, but what about moment?

How to I make it work?

already tried

global.moment = require('moment')
const moment = require('moment')

but still doesnt work,
can you give us some examples on your documentation on how we should add jQuery Plugin?

Vue is not yet complete, and cannot integrate to element the way jQuery does,
Vue has element reference but in terms of adding daterangepicker or other jquery plugin which need the existence of element and not part with VueJS Component,
Vue is component base,

I don't know if I made myself clear,

there is a jquery package that I want to use,
I use vue-good-table to display the list then there is a column filter on then I wan't the input text on column filter to be a datepicker, since the element is generated by vue-good-table I guess there is no way to to use the vue-datepicker component

Now Im thinking I should use jQuery datepicker to get the element and make it as dapicker, in that way the column filtering will still be at vue-good-table component :)

Now the reason I came to this repo is because, I didn't find any documentation that refers to adding the jquery plugins,
so the above content issue is what I tried in order to make the jQuery Datepicker work on Nuxt VueJS

Sorry for the rampant I guess :), I was stress cause I can't integrate or get a solution to this problem

As of now the issue is resolve, I found a way to implement by not using jquery plugin

question

Most helpful comment

Vue is not yet complete, and cannot integrate to element the way jQuery does,

E01EECA7-0834-4455-97CA-3DB0C08D8AC1

All 3 comments

Vue is not yet complete, and cannot integrate to element the way jQuery does,

E01EECA7-0834-4455-97CA-3DB0C08D8AC1

jQuery.... what year is this !

@alfligno Vue and jQuery have different philosophies of interacting with the DOM. Vue is mostly declarative (you declare how the DOM should reflect the data) but jQuery is imperative (you have methods you call to affect the DOM).

That said, it is technically possible to use jQuery plugins in Vue - even though I wouldn't recommend it. For example, https://vuejs.org/v2/examples/select2.html.

I'm going to close this issue but if you have any questions, you'd be more than welcome to bring them up on the Nuxt Discord channel.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

msudgh picture msudgh  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

vadimsg picture vadimsg  路  3Comments

vadimsg picture vadimsg  路  3Comments