在 Vue 2 中使用 属性 "route"

Using property "route" in Vue 2

我在视频中看到了这段 Vue 1 代码:

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

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

我正在使用 Vue 2 进行尝试。

"route:"下的数据函数根本就没有调用

"route:" 在 Vue 2 中被弃用了吗?

"route:" 的替代方法是什么?

"route:" 到底有什么意义?

Vue 2 的组件上没有名为 route 的函数。

您正在寻找 life-cycle hooks createdmounted

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