Egret 利用ImageLoader加载服务器图片

let self = this;
let url = "http://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erb9KD8YAjeDxh2z5yMaVxxtHEaPkkKTfRrDCU1UWbE0RrfE64aHiclZAtB2OkoFWSYBiaymbNpc5aQ/132";
let imgLoader = new egret.ImageLoader();
imgLoader.crossOrigin = "anonymous";// 跨域请求
imgLoader.load(url);// 去除链接中的转义字符‘\’
imgLoader.once(egret.Event.COMPLETE, function (evt: egret.Event) {
if (evt.currentTarget.data) {
egret.log("加载头像成功: " + evt.currentTarget.data);
let texture = new egret.Texture();
texture.bitmapData = evt.currentTarget.data;
let bitmap = new egret.Bitmap(texture);
bitmap.x = 200;
bitmap.y = 200;
self.addChild(bitmap);
}
}, this);


https://bbs.egret.com/thread-50162-1-2.html

你可能感兴趣的:(Egret 利用ImageLoader加载服务器图片)