0๐
- As you said you are using the latest vue version there is no more
ready
lifecycle hook, you can use themounted
hook instead. See Vue lifecycle hooks. - There is a scoping issue for
this
. Thethis
you use in yourready
function does not point to the vue instance. Use a fat arrow function instead or setup a variable pointing the correct vue instance and use that variable - Since you initialized
posts
property in you data property there is no nedd to useVue.set
All put together
mounted: function(){
var self = this;
posts = this.$resource('/wp-json/wp/v2/posts?per_page=20');
posts.get(function(posts){
self.posts = posts;
})
}
0๐
- Fetching After Navigation created hook
- Fetching Before Navigation beforeRouteEnter hook
Source:stackexchange.com