vue跳转相同路由(传递不同参数)时,该路由不刷新

  data() {
    
    
    return {
    
    
      id: '',
 
    }
  },
  mounted() {
    
    
    this.id = this.$route.query.id
    this.get_detail()  // 获取该路由页面内容的方法
  }, 
  watch: {
    
    
    $route(to, from) {
    
    
      // console.log(to)
      this.id = this.$route.query.id
      this.get_detail()
    },
  },

在watch里面监听路由的跳转,获取to过去的新路由携带的id

猜你喜欢

转载自blog.csdn.net/m0_49159526/article/details/109400284