//2.若依系统中如何解决同级路由组件之间的跳转缓存问题:
很简单:

  正常是  // created() {

  //   this.getList();

  //   this.getDeptTree();

  // },

这样的,存在路由缓存

现在使用:路由钩子:

  beforeRouteEnter (to, from, next) {

    // ...

    console.log("不用点击就刷新啦");

    next(vm => {

    // 调用实例的方法

    vm.getList();

    vm.getDeptTree();;

  });

  },

这样就行了。注意他的周期执行的时候还没有渲染好,所有不存在this.getList(),只能使用

vm.getList() 来调用。

Logo

快速构建 Web 应用程序

更多推荐