1.vue安装jquery插件
切换到当前项目下
cnpm i jquery@latest --save
#latest表示最新的jquery
2.找到vue的main.js
加入代码:
import $ from 'jquery';
window.$ = $;
3.这样就可以在对应的页面使用jquery了,给对应的input加class的时候,注意看对应的渲染后的html节点
<template>
<Input placeHolder="Enter task id..." v-model="tab1.task_id" style="width:200px" class="task_id"/>
</template>
<script>
export default {
data() {
return{
}
},
mounted() {
alert(window.$('.task_id').find('input').val());
},
destroyed() {
},
}
</script>
如上功能的实现特点:
1.这样就可以在vue项目中使用jquery了
2.主要使用了jquery的ajax同步执行机制,因为vue的axios执行不能同步请求的