-
在展示 要刷新的组件的 父组件中引入以下函数
<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>
-
在父组件中 展示 子组件的标签中使用
//组件引用 <div id="wendu"> <ECharts v-if="isRouterAlive"></ECharts> </div> //如果是路由 <router-view v-if="isRouterAlive/>
-
在要使用局部刷新的组件中 引入
export default { inject:['reload'], //接收 data() { return{ ...... } } }
-
调用:
this.reload();
vue组件无空白局部刷新
最新推荐文章于 2023-05-06 17:03:28 发布