【发布时间】:2020-10-29 01:34:13
【问题描述】:
我有:
async search() {
如何实现 lo dash 的告发?我试过了:
async search: _.debounce(function () {
但没有运气。
【问题讨论】:
-
什么是'await'在'function'前面?
我有:
async search() {
如何实现 lo dash 的告发?我试过了:
async search: _.debounce(function () {
但没有运气。
【问题讨论】:
试试这个:
<input type="text" @keypress="searchDebounce" />
methods: {
async search() {
// get search result
},
searchDebounce: _.debounce(async function() {
await this.search();
// or you can move everything from search() to here, and delete this.search()
}, 1000)
}
data() {
return {
searchDebounce: null
};
},
created() {
this.searchDebounce = debounce(this.search, 1000);
}
【讨论】: