VUE解决路由里的参数改变页面却没有跳转的问题

第一步:修改app.vue文件

<template>
  <div id="app">
    <div class="content">
      <router-view v-if="routerAlive">

      </router-view>
    </div>
  </div>
</template>

<script>
export default{
  data(){
    return{
      routerAlive: true,
    }
  },
  provide(){
    return{
      routerRefresh: this.routerRefresh
    }
  },
  methods:{
    routerRefresh(){
      this.routerAlive = false;
      this.$nextTick(()=>{
        this.routerAlive = true;
      });
    }
  }
}
</script>

<style>

</style>

第二步:在页面跳转相应的js文件export default中进行修改

添加一行:

inject: ['routerRefresh']

在跳转方法中修改:

let url = "/getList?ID=" + item.id;
this.$router.push(url);
this.routerRefresh();

版权声明:本文为hhh590_hh原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。