D
D
diafree2019-09-02 11:37:47
JavaScript
diafree, 2019-09-02 11:37:47

Using jQuery components in Vue?

Good afternoon.
How to properly use jQuery plugins in Vue components.
Inside the component, I connect the plugin like this:

import $ from 'jquery'
import mask from '../assets/jqplugins/jquery.maskedinput'


I use like this:
mounted() {
        $('mask.').mask("99/99/9999");
    }


But in the console there is an error ReferenceError: jQuery is not defined
Although jQuery works without plugins

(I use the mask plugin just for an example)

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
PEMOK, 2019-09-03
@PEMOK

Have you considered writing your own directive or component? On vue, there are no problems, or in extreme cases, use a ready-made one for vue. IMHO JQ in vue smacks of perversion, unexpected bugs, etc.

M
Marat Garifullin, 2019-09-04
@magarif

The problem is in the order of adding dependencies.
Look in the assembly how jQ and mask go. I'm sure the mask is connected before.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question