在云开发服务器里已经获取到了用户的信息,头像url也能查看,调试运行时能显示用户名字,但是不显示头像图片。网上找了无数办法了,怎么试都不行
onLoad () {
if(G.userInfo == null)return
let _url = G.userInfo.avatarUrl;
cc.loader.load({
url:_url,
type:‘jpg’
},function(err,texture){
var frame = new cc.SpriteFrame(texture);
if(err){
console.log(“用户头像”,err);
}
this.icon.getComponent(cc.Sprite).SpriteFrame = frame;
this.name.getComponent(cc.Label).string = G.userInfo.nickName;
}.bind(this));
},
1 个帖 - 1 位参与者