在使用vue框架開發(fā)的時候 ,是非常的方便的,但是在工作中 ,還是會有遇到對接jq的部分的接口,這個時候就需要在vue的界面里面引入jQuery并使用了
1:在項目里面安裝
npm install jquery --save

2:在項目里面找到.eslintrc.js文件打開并進(jìn)行配置
我們在env中配置 jQuery:true

3.打開項目的根目錄vue.config.js文件

4:在main.js文件中導(dǎo)入jquery
//引入jquery
import jquery from 'jquery'

5:使用案例
使用jquery寫一個點(diǎn)擊事件
test.vue
<template>
<div class="test">
<div class="click">點(diǎn)我</div>
</div>
</template>
<script>
export default {
name: "test",
date() {
return {};
},
mounted() {
this.text();
},
methods: {
text() {
$(".click").click(function () {
alert(1);
});
},
},
};
</script>
<style >
</style>
點(diǎn)擊按鈕出現(xiàn)alert彈框
