uniapp 开发app ,画布运行报错
canvas(){
let that = this;
let codeimg = that.codeimg;
// const ctxc = uni.createCanvasContext('qrcode',this);
const ctx = uni.createCanvasContext('myCanvas',that);
// const uqrcode = new uQRCode(
// {
// text: this.text,
// size: this.size
// },
// ctxc
// );
// uqrcode.make();
// uqrcode.draw();
setTimeout(() =>{
uni.canvasToTempFilePath({
canvasId: 'qrcode',
success: function(res) {
console.log(res)
// 在H5平台下,tempFilePath 为 base64
codeimg = res.tempFilePath
// that.codeurl = res.tempFilePath
// ctx.beginPath();
//图片
ctx.drawImage(that.itemPhotoUrls,0,0,266,266)
// console.log(that.imagesss,99999)
// ctx.drawImage(that.goodsDetail.itemPhotoUrls[0],0,0,266,266)
ctx.fillStyle = "#282828";
ctx.fillRect(0, 266, 266,146);
console.log(1)
//第一行文字
ctx.fillStyle="#E8E8E8";
ctx.font="14px Arial";
ctx.fillText('藏品信息早知道', 20, 290); //描绘文本
//第二行文字
ctx.fillStyle="#919191";
ctx.font="10px Arial";
ctx.fillText('关注发售日历 不错过每一份热爱', 20, 305)//描绘文本
//绘制图片
ctx.drawImage('../../static/popups.png',10,315,245,85)
ctx.drawImage('../../static/shearLogo.png',28,325,40,40)
//边框二维码
ctx.fillStyle = "#FFF";
ctx.lineJoin = "round";
ctx.fillRect(185,325,60,60);
//第三行文字
ctx.fillStyle="#ECB26A";
ctx.font="11px Arial";
ctx.fillText(that.itemIssuer, 80, 350)//描绘文本
// 第四行文字
ctx.fillStyle="#E8E8E8";
ctx.font="8px Arial";
ctx.fillText('扫码打开一千河APP,探索有趣的数字藏品', 28, 380)//描绘文本
// ctx.lineJoin = "round";
// ctx.lineWidth = 2;
ctx.drawImage('../../static/code.png',185,325,60,60);
ctx.strokeRect(0, 0, 266, 412);
ctx.draw(true, ()=>{
setTimeout(()=>{
uni.canvasToTempFilePath({
canvasId: 'myCanvas',
success: function(res) {
that.$refs.popups.open()
that.isShows = true;
// 在H5平台下,tempFilePath 为 base64
that.image = res.tempFilePath
}
})
},1000)
})
}
})
// that.canvas()
},500)
},
无法读取未定义的属性ready 。看起来是语法错误 。ready是你项目里用到了吗?你全局搜索一下 。 如果是 你项目里用到了 需要做个非空判断
判断 ready 存在 再使用
如果没有就是 库有问题