使用代码:
getContext(this).resourceManager.getRawFileContent('test.json')
.then(res=>{
console.log('xx' + res.toString())
}).catch((error:BusinessError) =>{
console.log(`xx error ${JSON.stringify(error)}`);
})
报错信息:
{“code”:9001005,“message”:“GetRawFileContent failed”}
HSP模块中默认获取的context为entry的context,需要创建moduleContext获取当前HSP模块的context。
参考代码: