1.安装jquery
npm install jquery --save-dev
2、在文件build/webpack.base.conf.js中配置
const webpack = require('webpack')
plugins: [
new webpack.ProvidePlugin({
$:"jquery",
jQuery:"jquery",
"windows.jQuery":"jquery"
})
],
3、在main.js中引入jquery
import $ from 'jquery'
提示:在用jquery的时候要加 $(function(){})
$(function(){
console.log('Holle')
})
4.最后重启项目就可以了
npm run dev