一. jQuery引入
1. 安装
npm install jquery --save
2. 引入
21. 局部引入,
在需要使用的页面进行引入
import $ from 'jquery'
22. 全局引入
在项目目录下build下的webpack.base.conf.js文件头部加入
var webpack = require('webpack')
并在module.exports的尾部加入
plugins: [
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery"
})
]
//如下
/* module.exports = {
//其它代码
plugins: [
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery"
})
],
} */
在main.js中引入
import $ from 'jquery'
重启服务&#x