A
A
Artem Kondratsky2019-09-20 19:43:50
JavaScript
Artem Kondratsky, 2019-09-20 19:43:50

How to use jQuery and its plugins in Vue?

To begin with, I will say that I googled . I found how to connect jQuery plugins to it , but it doesn't work properly. JQuery itself works fine, but when I try to initialize the plugin, it crashes

mistake

Uncaught ReferenceError: jQuery is not defined
    at eval (jaliswall.js?b0c2:118)
    at Module../public/js/jaliswall.js (app.js:2404)
    at __webpack_require__ (app.js:770)
    at fn (app.js:130)
    at eval (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/App.vue?vue&type=script&lang=js&:4)
    at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/App.vue?vue&type=script&lang=js& (app.js:933)
    at __webpack_require__ (app.js:770)
    at fn (app.js:130)
    at eval (App.vue?c53a:1)
    at Module../src/App.vue?vue&type=script&lang=js& (app.js:2428)


initialization code

.....
import $ from 'jquery'
import '../public/js/jaliswall'
...
mounted: function () {
    $('.main section.section.section-portfolio .wall').jaliswall({
      item: '.wall-item',
      columnClass: '.wall-column'
    })
  }
.....



How do I include jQuery and a plugin? There is also a ProvidePlugin plugin for Webpack, but I didn’t understand how to connect it and where, it seems, in the Webpack settings in the vue.config.js file. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Suha, 2019-09-20
@kondrackii

here you can read how to use ProvidePlugin. Well, how to use jq in vue is a piece of g ... on

P
PEMOK, 2019-09-21
@PEMOK

I didn't read it, I don't approve. It's like drawing with a pencil

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question