1. 下载jquery
命令:npm install jquery --save
2. 查看package.json
3. 修改webpack.base.conf.js的配置
var webpack = require("webpack");
plugins: [
new webpack.ProvidePlugin({
$:"jquery",
jQuery:"jquery",
"windows.jQuery":"jquery"
})
]
4. 引入jquery
在main.js中引入(或者按需引用,需要加上下面这句话)
import $ from "jquery"
5. 使用jquery
<template>
<div>
<button id="btn001" @click="clickEvent">click Me</button>
</div>
</template>
<script>
export default = {
methods:{
clickEvent:function(){
$("#btn01").css('display','none')
}
}
}
</script>