vue 刷新页面,不刷新浏览器,只刷新内容区域

 

provide、inject
 
app.vue中:
<template>
  <div id="app">
    <router-view v-if="isRouterAlive"></router-view>
  </div>
</template>
data(){
  return{
      isRouterAlive:true
  }
}
 methods: {
    reload() {
      this.isRouterAlive = false;
      this.$nextTick(() => {
        this.isRouterAlive = true;
      });
    },
  },
provide(){
        return{
            reload:this.reload
        }
    },
 
在使用刷新的页面:
inject: ["reload"]
this.reload()刷新页面,只刷新了内容区域
posted @ 2021-04-27 15:35  收藏小能手  阅读(824)  评论(0)    收藏  举报