在使用localStorage存储token和用户头像时,由于heard组件已经加载完毕,无法更新实时登录信息,所以采用以下方式进行强制刷新。

    1. toView(row) {
    2. this.forceRefresh = false
    3. // 强制刷新子组件
    4. this.$nextTick(() => {
    5. this.forceRefresh = true
    6. })
    7. }

    因为父组件有缓存等因素,子组件创建后没有释放,传入参数无效,使用v-if的特性(销毁和重建)可以强制刷新子组件