前端vue删除列表刷新页面

前端vue删除列表刷新页面

在App.vue中添加代码

<template>
  <div id="app">
    <router-view v-if="isRouterAlive" />
  </div>
</template>

<script>
  export default {
          
   
    name: App,
    provide() {
          
   
      return {
          
   
        reload: this.reload
      }
    },
    data() {
          
   
      return {
          
   
        isRouterAlive: true
      }
    },
    methods: {
          
   
      reload() {
          
   
        this.isRouterAlive = false
        this.$nextTick(function() {
          
   
          this.isRouterAlive = true
        })
      }
    },
  }
</script>

使用介绍 引入:

export default {
          
   
 inject: [reload],
  methods:{
          
   
  deleteBk(id) {
          
   
        var vm = this;
        this.axios({
          
   
          method: delete,
          url: http://localhost:7003/llcBk/delete?id= + id,
        }).then(function(response) {
          
   
          vm.$message.success(删除成功);
          //在这里使用就可以了
          vm.reload();
        })
      }
}
}
经验分享 程序员 微信小程序 职场和发展