Vue-cli webpack introduces jquery method, webpackjquery
After an afternoon's effort, I finally introduced jquery to the project generated by vue-cli and recorded it. (Webpack for Template)
Add "jquery": "^ 2.2.3" to dependencies in package. json, and then install
Add webpack. base. conf. js
var webpack = require("webpack")
Add module. exports
plugins: [new webpack.optimize.CommonsChunkPlugin('common.js'),new webpack.ProvidePlugin({jQuery: "jquery",$: "jquery"})]
Then run dev again.
It's okay to introduce it in main. js.import $ from 'jquery'
The following describes how to introduce jquery in vue.
1. Install jquery on npm
npminstall jquery --save
2. build/webpack. base. conf. js
plugins: [new webpack.optimize.CommonsChunkPlugin('common.js'),new webpack.ProvidePlugin({jQuery:"jquery",$:"jquery" })]
3. Introduce jquery in main. js
import $ from 'jquery'
4. eslint
The next step is to modify the. eslintrc. js file under the root directory. In the module. exports file, add a key value pair jquery: true for env.
Summary
The above section describes how to introduce jquery into vue-cli webpack. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!