vue vue-router beforeRouteEnter

beforeRouteEnter (to, from, next) {
    // 在渲染该组件的对应路由被 confirm 前调用
    // 不!能!获取组件实例 `this`
    // 因为当守卫执行前,组件实例还没被创建
  },
beforeRouteEnter 里面的变量不能使用this,即不能使用data函数中定义的变量,可以使用外面定义的变量(非组件内定义的变量)。

猜你喜欢

转载自www.cnblogs.com/mengfangui/p/9207186.html