1.npm install jquery –save ( npm install jquery)
2.webpack.config.js 中添加
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'jquery':'jquery'
}
},
plugins中添加如下:
new webpack.ProvidePlugin({
$: “jquery”,
jQuery: “jquery”
}),
3.main.js 中导入jQuery
import jquery from “jquery/tmp/jquery.js”(添加此行代码是看一下jQuery 路径)
4.app.vue 中导入jquery
import $ from “jquery”;