HarmonyOS鸿蒙Next中主模块下的资源rawfile下的index.html,使用web加载时可以使用"resource://rawfile/index.html",那么hsp包下的rawfile中的index.html如何以这种路径加载呀
HarmonyOS鸿蒙Next中主模块下的资源rawfile下的index.html,使用web加载时可以使用"resource://rawfile/index.html",那么hsp包下的rawfile中的index.html如何以这种路径加载呀 主模块下的资源rawfile下的index.html,使用web加载时可以使用"resource://rawfile/index.html",那么hsp包下的rawfile中的index.html如何以这种路径加载呀
可以通过Context.createModuleContext,先创建hsp的上下文,再用getRawFileContent获取内容:
getContext().createModuleContext('library').resourceManager.getRawFileContent(('bundle.harmony.js'));
可以参考文档:
更多关于HarmonyOS鸿蒙Next中主模块下的资源rawfile下的index.html,使用web加载时可以使用"resource://rawfile/index.html",那么hsp包下的rawfile中的index.html如何以这种路径加载呀的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
这种知道,没有像主模块那种resource协议的方式吗
目前hsp包中只有这种方式,
我们都是用har包,没用过hsp包。理论上路径是一样的啊!
在HarmonyOS鸿蒙Next中,主模块下的资源rawfile
中的index.html
可以使用"resource://rawfile/index.html"
路径加载。对于HSP包下的rawfile
中的index.html
,加载路径需要指定HSP包的名称。假设HSP包名为com.example.hsp
,则加载路径为"resource://com.example.hsp/rawfile/index.html"
。
在HarmonyOS鸿蒙Next中,HSP(Harmony Shared Package)包下的资源加载路径与主模块不同。要加载HSP包中rawfile
目录下的index.html
,可以使用路径格式"resource://模块名/rawfile/index.html"
。其中,模块名
是HSP包的名称。例如,如果HSP包名为com.example.hsp
,则路径为"resource://com.example.hsp/rawfile/index.html"
。确保在配置文件中正确声明HSP包的依赖关系。