image.createImageSource(imagePath) imagePath可以是https这种地址吗? HarmonyOS 鸿蒙Next

image.createImageSource(imagePath) imagePath可以是https这种地址吗? HarmonyOS 鸿蒙Next

【设备信息】Mate60

【API版本】Api13

【DevEco Studio版本】5.0.7.200

【问题描述】

```javascript
image.createImageSource(imagePath)

imagePath地址可以是https这种地址吗?

我用这个地址,一直返回的是空对象。 http://gips0.baidu.com/it/u=1690853528,2506870245&fm=3028&app=3028&f=JPEG&fmt=auto?w=1024&h=1024

createImageSource只能加载本地的路径吗?


更多关于image.createImageSource(imagePath) imagePath可以是https这种地址吗? HarmonyOS 鸿蒙Next的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

当前这个路径只支持应用沙箱路径,你可以先下载到沙箱路径中,再把沙箱路径传入createImageSource

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V13/js-apis-image-V13#imagecreateimagesource

更多关于image.createImageSource(imagePath) imagePath可以是https这种地址吗? HarmonyOS 鸿蒙Next的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在HarmonyOS中,image.createImageSource(imagePath) 方法用于创建图像源。imagePath 参数可以是本地文件路径,也可以是网络URL,包括 https 地址。因此,imagePath 可以是 https 这种地址。该方法支持从网络加载图像资源,并生成相应的图像源对象,用于后续的图像处理或显示操作。

回到顶部