Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

vue中使用Lodash 的debounce,一定要放在created里才能生效吗?

https://cn.vuejs.org/v2/guide...
把this.debouncedGetAnswer = _.debounce(this.getAnswer, 500)
改成debouncedGetAnswer:function(){_.debounce(this.getAnswer, 500)}放在methods里就无效。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

使用方法不正确

debouncedGetAnswer:_.debounce(function(){
    this.getAnswer()
}, 500)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...