[Vuejs]-Need this vue-router function translated to ecma script 2015

0👍

You can use certain features such as shorthand method names and slightly more compact arrow functions to make it looks more ES2015, but it won’t change the functionality:

route: {
    data() {
        return this.$http
            .get('/api/posts?sort=title&order=1')
            .then(posts => { this.table.posts = posts.data });
    }
},

You couldn’t replace the data hook function with an arrow functions, because this would refer to the wrong context (either to window or undefined), as its this would be defined by its surrounding lexical scope and could not be overriden.

Leave a comment