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) 
  • 1.
  • 2.
  • 3.

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
相关问题
HarmonyOS Image CAPI模块文档描述
583浏览 • 1回复 待解决
无法读取到hsp模块中rawfile文件
2833浏览 • 1回复 待解决
HarmonyOS Rawfilejson文件读取
958浏览 • 1回复 待解决
HarmonyOS RawFile文件拷贝
662浏览 • 1回复 待解决
Image组件无法设置长按事件
2675浏览 • 1回复 待解决
HarmonyOS rawfile文件如何获取URI
814浏览 • 1回复 待解决
HarmonyOS page和WebView无法设置透明
1220浏览 • 1回复 待解决
HarmonyOS 设置Image宽高比例ratio
1255浏览 • 1回复 待解决