vue中的beforeRouteEnter和beforeRouteLeave

1、beforeRouteEnter

进入页面之前

beforeRouteEnter函数体内获取不到this实例

beforeRouteEnter(to, from, next){
    //不能直接获取this实例
    next(vm => {
      if (from.query.checkFull) {
        vm._data.checked=true;
      }
    })
}

2、beforeRouteLeave

离开页面之前

beforeRouteLeave函数体内可以获取到this实例

beforeRouteLeave(to, from, next){
   //可以直接获取this实例
    if (to.path=='/prepage') {
         to.query.code=this.code;
    }
    next();
}

参考链接:https://www.csdn.net/tags/NtTaQg4sODQ3ODYtYmxvZwO0O0OO0O0O.html