Home > Article > Web Front-end > How to install jq in vue.js
How to install jq in vue.js: First install JQuery through the command "npm install jquery --save"; then modify the configuration file; then introduce JQuery in the main.js file; and finally restart the project.
The operating environment of this tutorial: windows7 system, vue2.0&&jquery1.0 version. This method is suitable for all brands of computers.
Recommended: "vue tutorial"
Install and use JQuery for ajax requests and a small number of DOM operations
vue.js The data rendering method is already very convenient and powerful, and there is no need to use JQuery for this operation
1. Install JQuery
npm install jquery --save
2. Modify the configuration file after successful installation
## Add the following code to the file webpack.base.conf.js under the #build folder: Add the header and introduce the file:var webpack=require("webpack")Add
# to module.exports ##
plugins: [ new webpack.ProvidePlugin({ jQuery: "jquery", $: "jquery" }) ]
import $ from 'jquery' //或 import jQuery from 'jquery'
4. Restart the project
npm run dev //或 npm run start
5. Access the packaged index.html file by npm run build The final js and css files cannot be found because the path is pointed incorrectly
Modify the index.js configuration in the config folder
Original configuration:
Modify to add a little bit.
The above is the detailed content of How to install jq in vue.js. For more information, please follow other related articles on the PHP Chinese website!