//绘制圆角头像
radiusHead: function(){
var that = this;
wx.downloadFile({
url: this.data.avatarUrl,//这是网络地址,没问题
success: function (res) {
const myHead = wx.createCanvasContext('head');
myHead.save();
myHead.beginPath();
myHead.arc(that.data.mypx * 44, that.data.mypx * 44, that.data.mypx * 44, 0, 2 * Math.PI);
myHead.clip();
myHead.drawImage(res.tempFilePath, 0, 0, that.data.mypx * 88, that.data.mypx * 88);
myHead.restore();
myHead.draw();
}
})
},
在本地真机测试都是可以的,但上传之后在体验版不执行wx.downloadFile
我也遇到过 var img = image.replace("http:", "https:"); 路径处理一下试试 微信用户信息返回的是https 不过网上浏览一次会变成http
因为需要下载