使用防抖做搜索功能,1s后请求接口
ipt(curVal, oldVal) {
clearTimeout(this.timeId)
this.timeId = setTimeout(() => {
this.getFaqList(curVal)
}, 1000)
}
},
点击后返回发现搜索框的文本还在,但请求接口的ipt参数为空,浏览器打印不为空,代码打印为空,后面采用vue的实例,给ipt赋值
document.getElementById("txt").focus();
console.log(this.ipt)
this.ipt == '' ? document.getElementById("tableDivOne").style.display = "none" : document.getElementById("tableDivOne").style.display = "block";
myVue.ipt = document.getElementById("txt").value
}