HarmonyOS Image组件加载网络图片,是否有占位图相关API?

HarmonyOS通过Image组件加载网络图片时,是否有占位图相关功能,类似SDWebImage 的placeholderImage功能。

/** 
 * Set the imageView `image` with an `url` and a placeholder. 
 * 
 * The download is asynchronous and cached. 
 * 
 * @param url         The url for the image. 
 * @param placeholder The image to be set initially, until the image request finishes. 
 * @see sd_setImageWithURL:placeholderImage:options: 
 */ 
- (void)sd_setImageWithURL:(nullable NSURL *)url 
placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT;
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
HarmonyOS
2024-09-03 11:41:32
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

可以使用alt属性设置占位图。

参考链接:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-image-V5#属性

示例代码:

Image("https://www.huawei.com/xxx.png")// 直接加载网络地址,请填写一个具体的网络图片地址 
  .alt($r('app.media.icon'))// 使用alt,在网络图片加载成功前使用占位图 
  .width(100) 
  .height(100) 
  • 1.
  • 2.
  • 3.
  • 4.
分享
微博
QQ
微信
回复
2024-09-03 16:52:56
相关问题
HarmonyOS image 组件占位图
1233浏览 • 1回复 待解决
HarmonyOS Image加载网络图片
781浏览 • 1回复 待解决
Image组件如何加载网络图片
3713浏览 • 1回复 待解决
HarmonyOS Image 加载网络图片问题
1986浏览 • 1回复 待解决
HarmonyOS如何使用Image占位图
1078浏览 • 1回复 待解决
关于Image组件加载网络图片的问题
1760浏览 • 1回复 待解决
HarmonyOS Image组件网络图片不显示
1498浏览 • 1回复 待解决
HarmonyOS Image组件无法显示网络图片
2420浏览 • 1回复 待解决
HarmonyOS Image组件网络图片缓存
1120浏览 • 1回复 待解决