vue功能实现一:重载页面

2019-06-17  本文已影响0人  冰Q

全部的,请看https://www.jianshu.com/p/93281f5c2b38

重载页面(最简单方法,直接在入口文件APP.vue处处理)

全局引用,不需要针对个别页面处理,简化开发工作量

const state = {
    isReload: false, // 是否需要重加载页面组件
}
// 是否需要重载
[IS_RELOAD](state) {
    state.isReload = !state.isReload;
}
<router-view class='router-view' v-if="isRouterAlive"></router-view>
// 设置data数据
isRouterAlive: true
// watch监听isReload状态
isReload(value) {
  // 一旦发生变化则重载组件
    this.isRouterAlive = false;
    this.$nextTick(() => {
      this.isRouterAlive = true;
    })
}
this.$store.commit('IS_RELOAD');
上一篇 下一篇

猜你喜欢

热点阅读