Why introduce jquery?
vue generally do not need to use jquery, but when we need to use a plug-in version of vue and because there is no use jquery, jquery then we need to introduce a
Installation, configuration and use of
①install, execute the following command
jQuery --save install npm // If the Taobao mirror can be used cnpm
② configuration, webpack.base.conf.js
// ... legacy code // add code var WebPACK the require = ( 'WebPACK' ) module.exports = { // ... legacy code plugins: [ new new webpack.ProvidePlugin ({ $: "jQuery" , the jQuery: "jQuery" , jQuery: "jQuery" , "window.jQuery": "jQuery" }) ], // ... legacy code }
③ use
After the installation configuration is complete we can use, the components need to be used in the introduction to the desired position
import $ from 'jquery'
If desired global settings can be introduced into app.vue
import $ from 'jquery' // //let $ = require('jquery') //window.$ = $