Closed wangshaolei closed 1 month ago
The log is crystal clear. You should call MMKV.initialize()
first.
Normally, you should initialize inside the EntryAbility.onCreate()
function.
If you have done that and the error still exists, you should make two breakpoints to see if the place you invoke MMKV runs before the place you initialize MMKV.
If you have done that and the error still exists, you should make two breakpoints to see if the place you invoke MMKV runs before the place you initialize MMKV.
我已经在EntryAbility onCreate 初始化了,app 程序正常运行,就是在使用的页面预览会报这个 Log 错误。我使用的是全局导出方式使用
import { MMKV } from '@tencent/mmkv'; class CacheKey { readonly LOGIN_TOKEN: string = "login_token" } export const cacheKey = new CacheKey() export const mmkv: MMKV = MMKV.mmkvWithID("app_cache")
If you have done that and the error still exists, you should make two breakpoints to see if the place you invoke MMKV runs before the place you initialize MMKV.
I will not repeat myself.
Note:
I invoke MMKV.initialize in EntryAbility onCreate and app work normal, But on the Component page using mmkv, the preview will give an error
The language of MMKV
The version of MMKV
The platform of MMKV
The installation of MMKV
What's the issue?
What's the log of MMKV when that happened?