在HSP中保存一个本地json文件,在本HSP中使用,获取到的是entry中的信息。
例如在xxx的HSP中的Resource目录下rawfile中一个yyy.json文件,获取此文件中的信息
let moduleContext = GlobalContext.getContext().createModuleContext("mgconfigcenter")
moduleContext.resourceManager.getRawFileContent("yyy.json", (error: BusinessError, value: Uint8Array) => {
if (error != null) {
console.error("error is " + error);
} else {
}
})
使用如下方法可以获取到element/string.json中的字符信息,但是无法获取rawfile中的信息。let result = moduleContext.resourceManager.getStringByNameSync('mgconfigLocal')
请问,如何获取rawfile下的内容。
hsp模块中默认获取的context为entry的context,需要创建moduleContext获取当前hsp模块的context。
一般是先根据模块名创建hsp对应的context,再根据创建的context获取rawfile内的内容。
可以参考如下调用方式: