ImageKnife提供图片加载成功失败的事件README补充

Signed-off-by: 任伟x <renwei79@h-partners.com>
This commit is contained in:
任伟x 2024-05-27 16:58:59 +08:00
parent 0d27e7a8cc
commit b777d40426
1 changed files with 17 additions and 0 deletions

View File

@ -144,6 +144,23 @@ async function custom(context: Context, src: string): Promise<ArrayBuffer | unde
ImageKnifeGlobal.getInstance().getImageKnife()?.replaceDataFetch(new CustomDataFetchClient());
```
### 8.监听图片加载成功与失败
```
ImageKnifeNextComponent({
imageKnifeNextOption: {
loadSrc: 'http://e.hiphotos.baidu.com/image/pic/item/4e4a20a4462309f7e41f5cfe760e0cf3d6cad6ee.jpg',
onLoadListener: {
console.log('Load Successful: ' + data);
return data;
},
onLoadFailed: (err) => {
console.error('Load Failed Reason: ' + err);
}
}
}
}).width(100).height(100)
```
## 进阶使用
如果简单的加载一张图像无法满足需求我们可以看看ImageKnifeOption这个类提供了哪些扩展能力。