setCanvas(){
let self = this;
//选取画板
const query = wx.createSelectorQuery()
query.select('#posterCanvas')
.fields({ node: true, size: true })
.exec(async (res) => {
const canvas = res[0].node;
//保存canvas实例
self.canvasObj = canvas;
const ctx = canvas.getContext('2d');
// canvas.width = res[0].width;
// canvas.height = res[0].height;
const dpr = wx.getSystemInfoSync().pixelRatio;
canvas.width = res[0].width * dpr;
canvas.height = res[0].height * dpr;
ctx.scale(dpr, dpr);
ctx.clearRect(0, 0, 320, 410); //清空画板
ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, 320, 410);
let txtLeftPos = 65;
ctx.textBaseline = "top";
ctx.textAlign = 'left';
ctx.font = "30px bold"; //设置字体大小,默认10
ctx.fillStyle = '#000'; //文字颜色:默认黑色
ctx.fillText("一键闪退", txtLeftPos, 295)//绘制文本
});
},
之后,我就报错。
搞不懂,更新个毛线,浪费我一天时间。你要更新要么给出案例来。不知道你更新后就留下介绍,是几个意思啊。
请具体描述问题出现的流程,并提供能复现问题的简单代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html