keepalive的bug修复问题

/**

  • @module tabsKeepAlive
  • @author: huoyou
  • @description: mescroll 缓存处理
    */
    export default {
    // mescrollType-1 普通mescroll
    // mescrollType-2 带tabs的mescroll
    mounted () {
    if (this.KaTeX parse error: Expected 'EOF', got '&' at position 22: …meta.keepAlive &̲& this.mescroll…refs.swiperTabs) {
    const { curIndex } = this. r e f s . s w i p e r T a b s c o n s t t i m e r = s e t T i m e o u t ( ( ) = > t h i s . t a b s [ c u r I n d e x ] . m e s c r o l l . s c r o l l T o ( 0 , 0 ) / / 初 始 化 滚 动 条 位 置 , 0 ) t h i s . refs.swiperTabs const timer = setTimeout(() => { this.tabs[curIndex].mescroll.scrollTo(0, 0) // 初始化滚动条位置 }, 0) this. refs.swiperTabsconsttimer=setTimeout(()=>this.tabs[curIndex].mescroll.scrollTo(0,0)//,0)this.once(‘hook: beforeDestroy’, () => {
    clearTimeout(timer)
    })
    }
    }
    },
    activated () {
    if (this.KaTeX parse error: Expected 'EOF', got '&' at position 22: …meta.keepAlive &̲& this.mescroll…route.meta.scrollTop || 0
    if (this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …Index } = this.refs.swiperTabs
    if (scrollTop !== 0) {
    this.tabs[curIndex].mescroll.scrollTo(scrollTop, 0) // 滚动到缓存的位置
    }
    }
    }
    },
    beforeRouteLeave (to, from, next) {
    if (from.meta.keepAlive) { // keepAlive=true为前提
    const arr = (from.meta && from.meta.whiteKeepAlive) || []
    if (this.mescrollType === 2) {
    if (this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …Index } = this.refs.swiperTabs
    this.tabs[curIndex].mescroll.hideTopBtn()
    }
    }
    if (!arr.includes(to.path)) {
    this.KaTeX parse error: Expected 'EOF', got '}' at position 43: … from.name) }̲ else { if…refs.swiperTabs) {
    const { curIndex } = this.$refs.swiperTabs
    from.meta.scrollTop = this.tabs[curIndex].mescroll.getScrollTop() // 缓存 滚动的位置到 meta.scrollTop
    }
    }
    }
    }
    next()
    }
    }

路由中写代码如下
{
path: ‘/xxxxxxxxx’,
name: ‘xxxxxxxxxxxx’,
meta: {
keepAlive: true,
whiteKeepAlive: [’/wisdom-analysis/subpage’] // 进入以下页面后再进入该页面,页面不刷新
},
component: () => import(’@/views/wisdom-analysis/wisdom.vue’)
},
保证name与页面name的一致性

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值