How can watch a property and invoke a function? I tried something like below but the reference to this is not the class object.
@Component({
components: {
Multiselect
},
watch: {
host: () => {
// this.analytics()
},
interval: () => {
// this.analytics()
}
}
})
Changing arrow function to plain function is enough.
@Component({
components: {
Multiselect
},
watch: {
host: function () {
this.analytics()
},
interval: function () {
this.analytics()
}
}
})
Thanks for your prompt response.
Changing arrow function to plain function is enough.
@Component({ components: { Multiselect }, watch: { host: function () { this.analytics() }, interval: function () { this.analytics() } } })
This works for me. Thank you bro
Most helpful comment
Changing arrow function to plain function is enough.
http://exploringjs.com/es6/ch_arrow-functions.html