s***@zhdbds.com
s***@zhdbds.com
  • 发布:2020-08-07 16:33
  • 更新:2022-07-12 21:50
  • 阅读:1493

【报Bug】v3版本下,使用keep-alive报错

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: window10 版本1803 ,内部17134.407

HBuilderX类型: 正式

HBuilderX版本号: 2.8.4

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: 荣耀v20

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<view class="bluetooth">  
  
<keep-alive>  
  
<component ref="bluetooth" :is="tabbarPath"></component>  
  
</keep-alive>  
  
<tab-bars></tab-bars>  
  
</view>

操作步骤:

使用keep-alive内置组件

预期结果:

可以使用keep-alive进行component缓存

实际结果:

无法使用,v3版本下app报错

bug描述:

v3下vue使用keep-alive会报错

Error in beforeCreate hook: "TypeError: undefined is not an object (evaluating 'r.data.attrs._i')" found in ---> <KeepAlive> TypeError: undefined is not an object (evaluating 'r.data.attrs._i')

注释掉keep-alive单独使用component正常,且在nvue页面使用keep-alive正常

2020-08-07 16:33 负责人:无 分享
已邀请:
Ammmm_一栩

Ammmm_一栩 - 落魄前端在线撸码

兄弟,我也遇到这个问题了,v3刚出来需要手动改json配置启用的时候我用是好的,后面正式版了就不行了,到现在都没有人解决

1***@qq.com

1***@qq.com

兄弟我也遇到了这个问题,解决了的话记得艾特我一下

1***@qq.com

1***@qq.com - 90后IT男

我也遇到了相同的报错0 0 请问楼主解决了吗

1***@qq.com

1***@qq.com - 90后IT男

keep-alive APP 上直接报和楼主一样的错误,H5没报错 但是没缓存效果

口区

口区 -

同样使用keep-alive报错

16:25:21.987 [Vue warn]: Error in beforeCreate hook: "TypeError: Cannot read property '_i' of undefined"
16:25:22.028 found in
16:25:22.069 ---> <KeepAlive>
16:25:22.089     at pages/index/index.vue:1
16:25:22.110 TypeError: Cannot read property '_i' of undefined
16:25:22.131 SyntaxError: Unexpected token u in JSON at position 0

  • 口区

    官方人呢


    2020-11-30 14:29

user_name

user_name

加一

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>  

要回复问题请先登录注册