HarmonyOS capi image node的source无法设置为rawfile的文件

目前没有办法将随app打包的rawfile路径设置给image node,请提供支持方案。

HarmonyOS
2024-12-27 16:45:54
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
aquaa

建议将图片放入resfile目录中,参考代码如下:

this.picturePath = this.context.resourceDir +'/test2.jpg' 
this.pictureUri = fileUri.getUriFromPath(this.picturePath) 
Image(this.pictureUri).height(40).width(40) 

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/resource-categories-and-access-V5#ZH-CN_TOPIC_0000001893210529__%E8%B5%84%E6%BA%90%E7%9B%AE%E5%BD%95

分享
微博
QQ
微信
回复
2024-12-27 18:22:20
相关问题
无法读取到hsp模块中rawfile文件
3092浏览 • 1回复 待解决
HarmonyOS Image CAPI模块文档描述
818浏览 • 1回复 待解决
HarmonyOS RawFile文件拷贝
920浏览 • 1回复 待解决
HarmonyOS Rawfilejson文件读取
1211浏览 • 1回复 待解决
Image组件无法设置长按事件
2879浏览 • 1回复 待解决
HarmonyOS rawfile文件如何获取URI
1126浏览 • 1回复 待解决
HarmonyOS page和WebView无法设置透明
1390浏览 • 1回复 待解决