在build文件夹下的webpack.base.conf.js文件
module.exports->resolve->alias
'jquery': path.resolve(__dirname, '../node_modules/jquery/src/jquery'),
'directives': path.resolve(__dirname, '../src/directives'),
如图
虽然webpack中有默认内置jquery,但是还是要install一下
cnpm install --save jquery
然后在app.vue中引入
import jQuery from 'jquery'
就可以使用了,如
mounted(){
this.city()
$(()=>{
$(".swiper").click(function(e){
console.log(e.target)
})
})
}