Vue introduces static jquery error reporting solutions: 1. Install jquery dependencies through "npm install jquery --save"; 2. Configure jquery in "vue.config.js"; 3. Through "import $ Just introduce jquery into the page by using "from "jquery";".
The operating environment of this tutorial: Windows 10 system, jquery version 3.2.1, DELL G3 computer
#What to do when vue introduces static jquery and reports errors ?
About the error when referencing jquery in vue
When jquery needs to be used in the vue project, we may have installed jquery and still get an error. How to solve it, as follows As shown:
1. Install jquery dependency npm install jquery --save
2. Configure jquery in vue.config.js
const webpack = require('webpack') module.exports = { chainWebpack: config => { config.plugin('provide').use(webpack.ProvidePlugin, [{ $: 'jquery', jquery: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery' }]) } }
3. Introduce it into the page
import $ from "jquery";
Recommended learning: "jQuery Video Tutorial"
The above is the detailed content of What to do if vue introduces static jquery and reports errors. For more information, please follow other related articles on the PHP Chinese website!