HarmonyOS 鸿蒙Next关于使用 tencent/mmkv(V1.3.7) 预览报错
HarmonyOS 鸿蒙Next关于使用 tencent/mmkv(V1.3.7) 预览报错
在页面使用 mmkv 引用的时候,app正常工作就是 UI无法预览错误log 如下:
[Engine Log]Lifetime: 0.000000s
07-24 09:45:35.351 5178…04194 C03900/Ace E [Engine Log]Js-Engine: ark
07-24 09:45:35.351 5178…04194 C03900/Ace E [Engine Log]page: pages/Login.js
07-24 09:45:35.351 5178…04194 C03900/Ace E [Engine Log]Error message: You should Call MMKV.initialize() first.
07-24 09:45:35.351 5178…04194 C03900/Ace E [Engine Log]SourceCode:
07-24 09:45:35.351 5178…04194 C03900/Ace E [Engine Log] throw new Error(‘You should Call MMKV.initialize() first.’);
07-24 09:45:35.351 5178…04194 C03900/Ace E [Engine Log] ^
07-24 09:45:35.351 5178…04194 C03900/Ace E [Engine Log]Stacktrace:
07-24 09:45:35.351 5178…04194 C03900/Ace E [Engine Log] at mmkvWithID (oh_modules/.ohpm/@tencent+mmkv@1.3.7/oh_modules/@tencent/mmkv/src/main/ets/utils/MMKV.ets:141:19)
07-24 09:45:35.351 5178…04194 C03900/Ace E [Engine Log] at func_main_0 (entry/src/main/ets/cache/CacheKey.ets:9:27)
有遇到的大佬吗,
HarmonyOS 鸿蒙Next使用tencent/mmkv(V1.3.7)预览报错,可能是因为未初始化MMKV或初始化时机不当。请确保在UI预览前已调用MMKV.initialize()
,并且检查初始化代码是否在全局或合适的生命周期中执行。同时,检查mmkv的依赖和鸿蒙系统版本是否兼容。如果问题依旧没法解决请加我微信,我的微信是itying888。