刚刚看到有人加载微信头像失败,然后想到可以发一下这个
if (!Utils.isEmpty(data.portrait)) { if (data.portrait.search(/.png|.jpg|.gif|.bmp/i) > 0) { cc.assetManager.loadRemote(data.portrait, function (err, texture) { if (!err && texture && that.portrait_sprite) { that.portrait_sprite.spriteFrame = new cc.SpriteFrame(texture); } }); } else { cc.assetManager.loadRemote(data.portrait, { ext: '.png' }, function (err, texture) { if (!err && texture && that.portrait_sprite) { that.portrait_sprite.spriteFrame = new cc.SpriteFrame(texture); } }); } } else { cc.resources.load("icon/portrait_0", cc.SpriteFrame, function (err, texture) { if (!err) { that.portrait_sprite.spriteFrame = texture; } }); }
