Closed xinle closed 4 months ago
import { MMKV } from '@tencent/mmkv';
@Entry @Component struct MMKVTestPage { build() { Row() { Column() { Button("save") .onClick(() => { let str: string = "{\"id\":5,\"name\":\"智能降噪\",\"desc\":\"保证人声和背景音无损伤的情况下,降低声音中的噪声\",\"isNeedVip\":false," + "\"downloadUrl\":\"GEpyiHCvL-PnJgxIcPL86hL_k" + "-GrUrFqfcZYWPMhDJmbDESu95nSbtIfEIbWua_EQgCf1S2oFNVBnCoukhs_mnkBFd6gT3H2f2XobvvjePhvLLiO-5Pqg6Rm_uPveVkW\",\"updateTime\":1699261134000,\"isNewProductFree\":false,\"isAuthorized\":true,\"effectVersion\":5,\"md5\":\"ee463c033e588c9da104755b1da020ca\",\"tags\":\"\",\"canLowDevice\":false,\"isValidMasterClassVip\":false,\"localPath\":\"/data/storage/el2/base/haps/MainApp/files/sound_effect/se_temp/un_zip_se_5__5\"}"; console.log("MMKVTest saveStr " + str) MMKV.defaultMMKV().encodeString('string', str); })
Button("get") .onClick(() => { let result = MMKV.defaultMMKV().decodeString('string') console.info('MMKVTest getStr = ', result); }) } .width('100%') } .height('100%')
} }
下面打印出来的结果会少一个字符串 ”}“
Duplicate with #1294
import { MMKV } from '@tencent/mmkv';
@Entry @Component struct MMKVTestPage { build() { Row() { Column() { Button("save") .onClick(() => { let str: string = "{\"id\":5,\"name\":\"智能降噪\",\"desc\":\"保证人声和背景音无损伤的情况下,降低声音中的噪声\",\"isNeedVip\":false," + "\"downloadUrl\":\"GEpyiHCvL-PnJgxIcPL86hL_k" + "-GrUrFqfcZYWPMhDJmbDESu95nSbtIfEIbWua_EQgCf1S2oFNVBnCoukhs_mnkBFd6gT3H2f2XobvvjePhvLLiO-5Pqg6Rm_uPveVkW\",\"updateTime\":1699261134000,\"isNewProductFree\":false,\"isAuthorized\":true,\"effectVersion\":5,\"md5\":\"ee463c033e588c9da104755b1da020ca\",\"tags\":\"\",\"canLowDevice\":false,\"isValidMasterClassVip\":false,\"localPath\":\"/data/storage/el2/base/haps/MainApp/files/sound_effect/se_temp/un_zip_se_5__5\"}"; console.log("MMKVTest saveStr " + str) MMKV.defaultMMKV().encodeString('string', str); })
} }
下面打印出来的结果会少一个字符串 ”}“