admin管理员组文章数量:1317915
Is there any solution to use lodash debounce on method? I also need 'this' in the function. Example:
data() {
info: 'Read Me!'
},
methods: {
readData() {
console.log(this.info)
}
}
In Vue2 I could use:
methods: {
readData: debounce(function() {
console.log(this.info)
}, 500)
}
Is there any solution to use lodash debounce on method? I also need 'this' in the function. Example:
data() {
info: 'Read Me!'
},
methods: {
readData() {
console.log(this.info)
}
}
In Vue2 I could use:
methods: {
readData: debounce(function() {
console.log(this.info)
}, 500)
}
Share
Improve this question
edited Oct 3, 2020 at 17:06
Boussadjra Brahim
1
asked Oct 3, 2020 at 16:28
BlablablaBlablabla
3054 silver badges11 bronze badges
1 Answer
Reset to default 7Your data property should be a function that returns an object :
data() {
return{
info: 'Read Me!'
}
},
and write your method by giving a name to the debounce callback :
methods: {
readData: debounce(function debounceRead() {
console.log(this.info)
}, 500)
}
本文标签: javascriptUse Vuejs 3 with lodash debounce functionStack Overflow
版权声明:本文标题:javascript - Use Vue.js 3 with lodash debounce function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742024729a2415325.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论