I'm using lodash to call a debounce function on a component like so:
...
import _ from 'lodash';
export default {
store,
data: () => {
return {
foo: "",
}
},
watch: {
searchStr: _.debounce(this.default.methods.checkSearchStr(str), 100)
},
methods: {
checkSearchStr(string) {
console.log(this.foo) // <-- ISSUE 1
console.log(this.$store.dispatch('someMethod',string) // <-- ISSUE 2
}
}
}
- Issue 1 is that my method
checkSearchStr
doesn't know aboutfoo
- Issue 2 is that my store is
undefined
as well
Why doesn't my method know this
when called through _.debounce
? And what is the correct usage?