前置准备
imageKnife安装:
ohpm install @ohos/imageknife
imageKnife请求网络gif的时,需要开通网络权限,在使用imageknife的模块module.json5中添加网络权限:
"requestPermissions": [
{
"name": "ohos.permission.INTERNET",
"usedScene": {
"abilities": [
"EntryAbility"
],
"when": "always"
}
}]
在项目内初始化ImageKnifeOption,配置请求头和加载图片的基本参数:
@State option: ImageKnifeOption = {
loadSrc: $r('app.media.startIcon'),//resources资源加载,默认icon
headerOption: [{
key: "refer",
value: "https://1.94.37.200:7070/AntiTheftChain/downloadImage"
}],//请求头
p