async onLoad(){
var that = this;
wx.downloadFile({
url: that.imgStr, // 资源地址
success(res) {
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if (res.statusCode === 200) {
that.imgFilePath = res.tempFilePath;
that.$apply();
that.drawImg();
console.log(res);
}
}
})
that.$apply();
/* ctx.draw(false, function () {
// wx.canvasToTempFilePath这个一定要写在ctx.draw里面的回调里面,是坑勿跳
wx.canvasToTempFilePath({
canvasId: "shareCanvas",
destWidth: 600,
destHeight: 800,
quality: 1,
success: function (res) {
console.log(res.tempFilePath)
callback(res.tempFilePath)
},
fail: function (res) {
console.log(res)
}
})
}) */
}
async drawImg(){
var postersize = this.setCanvasSize(750);//动态设置画布大小
console.log(postersize);
const ctx = wx.createCanvasContext('shareCanvas',this);
console.log(this.imgFilePath);
ctx.drawImage(this.imgFilePath, 0, 0, postersize.w, postersize.h);
ctx.drawImage(this.imgFilePath, 30, 30, postersize.w, postersize.h);
console.log(this.imgFilePath);
ctx.draw();
}
微信小程序开发问题解答
微信小程序开发者回答:
点右上角的...,有个 打开调试。。。
微信小程序开发者回答:
大神啊 请快帮忙啊 崩溃了
本文网址:http://www.91bianli.com/weixinxiaochengxu/6219.html