Home > Article > Web Front-end > Does vue have jquery built in?
There is no built-in jquery in vue; if you want to use specific functions of jquery in vue, you need to introduce the jquery package. Introduction method: 1. Modify "package.json" and add the jquery version; 2. Enter "npm install" in the terminal and import the dependencies; 3. Modify the "webpack.base.conf" code; 4. Use "import $ from ' jquery'" can be introduced.
The operating environment of this tutorial: windows10 system, Vue3&&jquery3.4.1 version, Dell G3 computer.
vue does not have built-in jquery
It is completely feasible to use jQuery in the Vue project, and it is completely in line with Vue’s working ideas. In essence, jQ is regarded as Just use it as a Vue plug-in that is not highly adaptable to Vue. You need to complete the two-way binding work yourself.
Using jquery in Vue
In a vue project, when you need to implement certain specific functions, it is not easy to implement it using the mvvm mode. Therefore, the jquery package is introduced to complete the requirements
1. Modify package.json
First, add "jquery" to the dependencies in package.json: "^2.2.3"
Of course you can modify the version you want to introduce. Here is the introduction of 2.2.3
2. Import dependencies
Enter npm install in the terminal to import dependencies.
3. Modify webpack.base.conf
The code is as follows, see the picture to modify;
var webpack = require("webpack")rrree
4. Introduce jquery into the component and use it
In which component we want to use the jQuery library, we must first use the following command to introduce jquery, and then It can be used normally
Here we introduce it globally in main.js
plugins: [ new webpack.ProvidePlugin({ $:"jquery", jQuery:"jquery", "windows.jQuery":"jquery" }) ],
Video tutorial recommendation:jQuery video tutorial
The above is the detailed content of Does vue have jquery built in?. For more information, please follow other related articles on the PHP Chinese website!