HarmonyOS NEXT - Stage模型应用 - 坑点-PersistentStorage的持久化重启应用失败问题
·
HarmonyOS NEXT - Stage模型应用 坑点-PersistentStorage的初始化要写在页面的 Entry 上方进行初始化,否则持久化容易失效。
如:需要在应用入口 @Entry 初始化 PersistentStorage
import { Home } from '@ohos/home';
import { SimpleMode } from '@ohos/home';
import { BreakpointConstants, CommonConstants, AppStorageSystemKey} from '@ohos/commons';
import { BusinessError } from '@kit.BasicServicesKit';
import router from '@ohos.router';
/**
* 坑点-PersistentStorage的初始化要写在页面的 Entry 上方进行初始化,否则持久化容易失效。
*/
PersistentStorage.persistProp("LOCAL_STORAGE","");
@Entry
@Component
struct Index {}
更多推荐


所有评论(0)