Adrian Padmodihardjo
1 min readJan 29, 2019

--

If you meant to access the Vue Instance then,

`this` equals undefined in a lot of different times, e.g. in beforeCreate lifecycle, beforeRouteEnter router hooks.

Also, using `this` in Vue template, like the following:

<div @click=”this.click”></div>

…would give a ReferenceError, since `this` won’t ever point to the instance scope. Reason why, if you look at how vue-template-compiler works, you see that Vue passes the instance scope using `with(this){…}` function.

So, `this.click` in above template would simply equals to `this[‘this.click’]`.

--

--