This repository has been archived by the owner on Nov 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,12 +57,17 @@ export default { | |
} | ||
}, | ||
methods: { | ||
searchNewsByKey: _.throttle(function() { | ||
this.keyword && | ||
searchNewsByKey(this.keyword).then((list = []) => { | ||
this.list = list; | ||
}); | ||
}, 1e3), | ||
/** | ||
* 使用 lodash.debounce 节流,每输入 600ms 后执行 | ||
* 不要使用箭头函数,会导致 this 作用域丢失 | ||
* @author mutoe <[email protected]> | ||
*/ | ||
searchNewsByKey: _.debounce(function() { | ||
if (!this.keyword) return; | ||
searchNewsByKey(this.keyword).then((list = []) => { | ||
this.list = list; | ||
}); | ||
}, 600), | ||
onRefresh(callback) { | ||
searchNewsByKey(this.keyword, 15).then(list => { | ||
this.list = list; | ||
|