The method of introducing jquery in VUE-CLI
Previously wrote Vue Project did not introduce jquery, today, a small group of friends asked me this question, I have to do a bit, the method is as follows:
Let's go into the Webpack.base.conf.js file and start at the top so we need to add a line of code
Become this
varPath = require ('Path')varUtils = require ('./utils')varWebpack = require ("Webpack")//This is the one we addedvarConfig = require ('.. /config')varVueloaderconfig = require ('./vue-loader.conf')
and join the module.exports inside.
plugins: [ new webpack.optimize.CommonsChunkPlugin ('common.js') ), new webpack. Provideplugin ({ "jquery", "jquery " }) ],
We introduced webpack in order to use Webpack object here;
Then add "jquery" to the dependencies in Package.json, "^1.8.0", or you can use NPM install Xxx-save to generate
And then we'll be able to import jquery into the main.js.
Finally, restart the project
At the end of the year, go to the waves.
The method of introducing jquery in VUE-CLI