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()刷新页面,只刷新了内容区域
                    
                
                
            
        
浙公网安备 33010602011771号