Vue跳转相同路由不同参数,解决页面数据不自动刷新

参考:

https://www.cnblogs.com/ainyi/p/9340311.html

https://blog.csdn.net/weixin_41888813/article/details/86735664

  created() {
    this.fetchLink()
  },

  watch: {
    // 监听相同路由下参数变化的时候,从而实现异步刷新
    '$route'(to,from) {
      // 做一些路由变化的响应
      this.loading = true;
      this.fetchLink()
    }
  },

  methods: {
    fetchLink(){
      resourcemgApi.zypriceSearch(this.$route.params.name).then(resp => [
        this.list = resp.data,
        console.log(this.list)
      ])
    }
  },

猜你喜欢

转载自www.cnblogs.com/flypig666/p/11762640.html