html:
<input bindinput="bindKeyInput" value="{{keyword}}" placeholder="搜索学校" bindfocus="focusevent"/>
js:
bindKeyInput(e){
var key = e.detail.value,
that = this
if (Interval) {
clearTimeout(Interval)
Interval = null
}
Interval = setTimeout(function () {
that.setData({
keyword: key
})
if (key != '') {
that.search(e)
}
clearTimeout(Interval)
Interval = null
}, 500)
},
search(){
let params ={
keyword:this.data.keyword,
}
ApiRequest.getSchool(params).then(res=>{
this.setData({
schoolList:res
})
})
},