@@ -593,8 +593,8 @@ export default {
}
},
clearSearch() {
- if (this.$refs.appSearch) {
- this.$refs.appSearch.inputEmptyFn();
+ if (this.$refs.appSearch && typeof this.$refs.appSearch.inputEmptyFn === 'function') {
+ this.$refs.appSearch.inputEmptyFn()
this.closeMore();
this.customId = 0;
@@ -121,6 +121,14 @@ export default {
if (!this.clearOnFocus) {
return
+ this.inputEmptyFn()
+ },
+ // 清空搜索框,供父组件「清空」按钮调用
+ inputEmptyFn() {
+ if (this.timer) {
+ clearTimeout(this.timer)
+ this.timer = null
+ }
this.search = ''
this.$emit('input', this.search)