在vue项目中引入jquery步骤:
1.安装jquery
npm install jquery
2.在webpack.base.conf.js配置
var webpack = require('webpack')
plugins: [
new webpack.optimize.CommonsChunkPlugin('common.js'),
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery"
})
]

3.在main.js里引入
import $ from 'jquery'
这样就可以在vue文件里直接使用$了。
网友评论