nuxt.js同路由跳转参数不同,mounted不执行时

watch: {
    '$route'(to, from) {
      if (to.fullPath !== from.fullPath) {
        this.$nextTick(() => { // 不加this.$nextTick时,路由跳转后还是上一次的数据,所以需要加上
          this.myfunction() // 需要执行的方法
        })
      }
    }
  },

同路由跳转,参数不同,mounted不执行是因为页面没有销毁,所以不会执行
当参数变化时,可以监听路由变化,来做一些事情

 

来源:https://www.jianshu.com/p/8ed29ca1c63c

posted @ 2021-08-19 12:03  study_php_java_C++  阅读(713)  评论(0编辑  收藏  举报