I am creating a component with Vue.js.
When I refer to this on any of the lifecycle hooks ( created , mounted , updated , etc.) it evaluates to undefined :
mounted: () => { console.log(this); // logs "undefined" },
The same thing happens inside my computed properties:
computed: { foo: () => { return this.bar + 1; } }
I get the following error:
Uncaught TypeError: Cannot read the 'bar' property from undefined
Why does this evaluate undefined in these cases?
thanksd
source share