7***@qq.com
7***@qq.com
  • 发布:2022-06-08 15:44
  • 更新:2022-07-12 21:51
  • 阅读:524

【报Bug】【再问】uni-app 路由緩存怎么实现?H5端 是否能支持页面的keep-alive呢?

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows10

HBuilderX类型: 正式

HBuilderX版本号: 3.4.14

浏览器平台: Chrome

项目创建方式: HBuilderX

操作步骤:

见问题

预期结果:

H5端起码能路由缓存

实际结果:

见问题

bug描述:

2022-06-08 15:44 负责人:无 分享
已邀请:
DCloud_UNI_WZF

DCloud_UNI_WZF

keep-alive 只支持 H5 端,使用参考如下代码:

<template>  
    <view>  
        <keep-alive :include="componentsName">  
            <component :is="componentsName[currentComponentIndex]"></component>  
        </keep-alive>  
        <button type="primary" @click="changeComponent">changeComponent</button>  
    </view>  
</template>  
<script>  
    import Foo from '../../components/Foo.vue'  
    import Bar from '../../components/Bar.vue'  
    export default {  
        components: {  
            Foo,  
            Bar  
        },  
        data() {  
            return {  
                componentsName: ['Foo', 'Bar'],  
                currentComponentIndex: 0  
            }  
        },  
        methods: {  
            changeComponent() {  
                this.currentComponentIndex = !this.currentComponentIndex * 1  
            }  
        }  
    }  
</script>  

该问题目前已经被锁定, 无法添加新回复