creator 动态加载微信头像,显示不了头像

先贴上代码:
private _iconUrl:string = “https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKialAsAVNqhX1iaHOnvdnRtI6wvGX9qwMvMdGYTbfIHoUMvPjn4Ml4mOCcJJYribFPhZS6brkL0bXfA/0

let icon_sprite = this.icon_player.getComponent(Sprite) as Sprite;
assetManager.loadRemote(this._iconUrl, {type: ‘png’}, function (err, imageAsset) {
const spriteFrame = new SpriteFrame();
const texture = new Texture2D();
texture.image = imageAsset;
spriteFrame.texture = texture;
icon_sprite.spriteFrame = spriteFrame;
});

由于获取到的图片是"jpg"格式的,参数{type:“jpg”}也尝试过,图片还是显示不了,使用creator3.1版本

你试下url后面补上 ?.jpg 看看。



测试代码,正常加载。对比参考下。

1赞

{type: ‘png’}换成{ext: ‘.png’}

我看3.1的文档里面用的是{type:".png"}

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。