[Vuejs]-WordPress title no showing with rest api using vue.js

0๐Ÿ‘

  1. As you said you are using the latest vue version there is no more ready lifecycle hook, you can use the mounted hook instead. See Vue lifecycle hooks.
  2. There is a scoping issue for this. The this you use in your ready 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
  3. Since you initialized posts property in you data property there is no nedd to use Vue.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๐Ÿ‘

Data Fetching

  1. Fetching After Navigation created hook
  2. Fetching Before Navigation beforeRouteEnter hook

Leave a comment