@@ -85,6 +85,7 @@ Page({
classId: "",
className: "",
+ timer: null as any,
isSaveDisable: false
},
async onLoad(options: any) {
@@ -298,8 +299,16 @@ Page({
})
onSearchChange(e: any) {
- this.setData({
+ const that = this
+ that.setData({
searchName: e.detail
+ }, () => {
+ // 防抖
+ clearTimeout(that.data.timer); // 清除之前的定时器
+ that.data.timer = setTimeout(() => {
+ that.getSchools(that.data.searchName);
+ // 这里写业务逻辑
+ }, 500);
onSearch() {