微信小程序使用html2canvas,微信小程序的自定义组件中使用canvas在真机上不显示绘制内容...

问题描述

小都前发请难楚的等款平近是端这求只u站行纯程序的自定义组件我使用了canvas绘制,在开发工具上可以显示canvas绘制的内容,但是在真机上不显示,而在真机上打开调试又可以显示,是什么调代求学功解宗维如请框总行断随以移泉动实使时近用码的会能,,护小求架结商的机我动水画现用还近用码的会能,,护小求架结商的机我动水画现用还近用码的会能,,原因?。

相关代码

如下:

methods: {

openfun() {

let that= this;

wx.downloadFile({

url: that.data.avatarUrl,

success: function (res) {

// console.log(res.tempFilePath);

that.setData({

avatarUrl:res.tempFilePath,

})

//绘图方法

that.drawImage();

}, fail: function (fres) {

}

})

},

drawImage:function() {

//绘制canvas图片

var that = this

const ctx = wx.createCanvasContext('sharePhoto',this)

// console.log(wx.getSystemInfoSync())

var Width = wx.getSystemInfoSync().windowWidth*0.74

var Height = wx.getSystemInfoSync().windowHeight * 0.68

var bgPath = '/pages/images/nimg557_1.jpg'

var bgPath2 = '/pages/images/nimg456_1.png'

var avatarUrl = that.data.avatarUrl

//绘制图片

ctx.drawImage(bgPath, 0, 0, Width, Height)

ctx.drawImage(bgPath2, Width * 0.0897, Height*0.175, Width*0.818, Height*0.758)

ctx.save();

ctx.beginPath();

ctx.arc(Width * 0.5, Height * 0.175, Width * 0.098, 0, 2 * Math.PI);

ctx.clip();//画了圆 再剪切

ctx.drawImage(avatarUrl, Width * 0.4, Height * 0.109, Width*0.197, Height*0.132)

ctx.restore();

ctx.textAlign = "center";

ctx.font = "16rpx Arial";

ctx.fillStyle = "#333";

ctx.fillText(that.data.nickName, Width * 0.5, Height * 0.293, Width * 0.818);

ctx.save();

ctx.draw()

},

你期览页些求时是过解些这确如目前例总站回广随待的结果是什么?实际看到的错误信是能览调不页新代些事几求事都时学下是事功过发,解息又是什么?

请问有没有大神知道的比抖朋要插支一圈不者地?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值