1 因为页面有多个input 所以其他input值变化也会走这个 wathc中的事件,虽然这个a.b的值没有变化
watch: {
'a.b': {
handler(val) {
document.onkeyup = (e) => {
console.log(123)
//调用接口
}
},
deep: true,
immediate: true,
},
},
3 需要加一个id 定位只给需要的input加事件
watch: {
'a.b': {
handler(val) {
document.getElementById('el-input').onkeyup = (e) => {
console.log(123)
//调用接口
}
},
deep: true,
immediate: true,
},
},
<el-form-item label="3.我的组织" prop="orgName" class="position-form-item">
<div style="margin-top: 15px">
<el-input
id="el-input-orgName"
placeholder="请输入关键字"
v-model="a.b"
class="input-with-select"
@focus="focus"
>
</el-input>
b
</div>
</div>
因为页面有好多input 所以需要单独处理 添加一个id