uni-app 京东小程序canvas点击事件无效

yi0zb3m4  于 9个月前  发布在  uni-app
关注(0)|答案(2)|浏览(135)

问题描述
京东小程序canvas点击事件无效,无论是外围包裹view还是cover-view,tap事件也无效

组件:
<cover-view @click="show" style="width: 90%;height: 600rpx;background-color: #0097ff;">
<canvas @touchstart="show" @touchmove="show" @touchend="show" @click="show" @tap="show" canvas-id="myCanvas">

js:

show(){
console.log('2222222')
},
draw(){
const ctx = uni.createCanvasContext('myCanvas')

  1. // Draw coordinates
  2. ctx.arc(100, 75, 50, 0, 2 * Math.PI)
  3. ctx.setFillStyle('#EEEEEE')
  4. ctx.fill()
  5. ctx.beginPath()
  6. ctx.moveTo(40, 75)
  7. ctx.lineTo(160, 75)
  8. ctx.moveTo(100, 15)
  9. ctx.lineTo(100, 135)
  10. ctx.setStrokeStyle('#AAAAAA')
  11. ctx.stroke()
  12. ctx.setFontSize(12)
  13. ctx.setFillStyle('black')
  14. ctx.fillText('0', 165, 78)
  15. ctx.fillText('0.5*PI', 83, 145)
  16. ctx.fillText('1*PI', 15, 78)
  17. ctx.fillText('1.5*PI', 83, 10)
  18. // Draw points
  19. ctx.beginPath()
  20. ctx.arc(100, 75, 2, 0, 2 * Math.PI)
  21. ctx.setFillStyle('lightgreen')
  22. ctx.fill()
  23. ctx.beginPath()
  24. ctx.arc(100, 25, 2, 0, 2 * Math.PI)
  25. ctx.setFillStyle('blue')
  26. ctx.fill()
  27. ctx.beginPath()
  28. ctx.arc(150, 75, 2, 0, 2 * Math.PI)
  29. ctx.setFillStyle('red')
  30. ctx.fill()
  31. // Draw arc
  32. ctx.beginPath()
  33. ctx.arc(100, 75, 50, 0, 1.5 * Math.PI)
  34. ctx.setStrokeStyle('#333333')
  35. ctx.stroke()
  36. ctx.draw()
  37. },

预期结果
[点击canvas运行show函数

实际结果
[这里请贴上你的报错截图或文字]

系统信息:

  • 发行平台: 京东小程序
  • 操作系统 安卓
  • HBuilderX版本 3.4.7.20220422

补充信息
[可选]
[]

2ic8powd

2ic8powd1#

在ide上可以,真机上面无效

cuxqih21

cuxqih212#

不使用uni-app时是否正常?

相关问题