小程序
小游戏
企业微信
微信支付
扫描小程序码分享
开发者工具中看正常,在真机上看就不正常,下图是真机,可以看到右上方线段有点残缺。
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
//.wxml文件如下
<canvas type="2d" id="myCanvas" style="width:98%;height:700rpx;border:1rpx solid #999"></canvas>
//.js文件中在onReady内写的内容如下
onReady: function () {
const query = wx.createSelectorQuery()
query.select('#myCanvas')
.fields({ node: true, size: true })
.exec((res) => {
const canvas = res[0].node
const ctx = canvas.getContext('2d')
const systemInfo = wx.getSystemInfoSync()
const dpr = systemInfo.pixelRatio
canvas.width = res[0].width * dpr
canvas.height = res[0].height * dpr
ctx.scale(dpr, dpr)
this.ctx = ctx
ctx.strokeStyle='#FF7F00'
ctx.lineWidth=2
ctx.beginPath()
ctx.moveTo(100,100)
ctx.lineTo(110,50)
ctx.lineTo(112,110)
ctx.lineTo(120,120)
ctx.lineTo(150,10)
ctx.stroke()
})
},
本回答由AI生成,可能已过期、失效或不适用于当前情形,请谨慎参考
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
//.wxml文件如下
<canvas type="2d" id="myCanvas" style="width:98%;height:700rpx;border:1rpx solid #999"></canvas>
//.js文件中在onReady内写的内容如下
onReady: function () {
const query = wx.createSelectorQuery()
query.select('#myCanvas')
.fields({ node: true, size: true })
.exec((res) => {
const canvas = res[0].node
const ctx = canvas.getContext('2d')
const systemInfo = wx.getSystemInfoSync()
const dpr = systemInfo.pixelRatio
canvas.width = res[0].width * dpr
canvas.height = res[0].height * dpr
ctx.scale(dpr, dpr)
this.ctx = ctx
ctx.strokeStyle='#FF7F00'
ctx.lineWidth=2
ctx.beginPath()
ctx.moveTo(100,100)
ctx.lineTo(110,50)
ctx.lineTo(112,110)
ctx.lineTo(120,120)
ctx.lineTo(150,10)
ctx.stroke()
})
},