trogne
trogne

Reputation: 3552

Using property "route" in Vue 2

I saw this Vue 1 code in a video :

export default {
    data () {
        return {
            sections: []
        }
    },

    route: {
        data () {
            return store.getSections().then(sections => {
                this.sections = sections;
            })
         }
    }
}

I'm trying this with Vue 2.

The data function under "route:" is simply not called.

Is "route:" deprecated in Vue 2 ?

What is the alternative to "route:" ?

And what's the point of "route:" after all ?

Upvotes: 0

Views: 37

Answers (1)

Ohgodwhy
Ohgodwhy

Reputation: 50787

There is no function named route on components in Vue 2.

You're looking for the life-cycle hooks created or mounted.

mounted: function() {
     return store.getSections().then(sections => {
            this.sections = sections;
        })
}

Upvotes: 1

Related Questions