本文编辑: JeremyLu浏览 5095
版权所有,严禁转载
canvas画布,你可以理解为有一张白布,你可以在画布上画出不同形状、颜色、粗细的图形。

wxml
<canvas class="canvas1" canvas-id="canvas1" bindtouchstart="mytouchstart" bindtouchmove="mytouchmove" bindtouchend="mytouchend"></canvas>
js
Page({
...
mytouchstart: function(e){
console.log('touchstart')
},
mytouchmove: function(e){
console.log('touchmove')
},
mytouchend: function(e){
console.log('touchend')
}
...
})
wxss
.canvas1{
background-color: #E0E0E0;
}
| 属性 | 类型 | 描述 |
|---|---|---|
| canvas-id | String | canvas组件唯一标识符 |
| disable-scroll | Boolean | 当手指在canvas上移动时,是否允许页面下拉刷新和页面滚动 |
| bindtouchstart | EventHandle | 绑定手指开始触摸事件 |
| bindtouchmove | EventHandle | 绑定手指触摸移动事件 |
| bindtouchend | EventHandle | 绑定手指触摸结束事件 |
| bindtouchcancel | EventHandle | 绑定手指触摸意外中断事件,例如弹窗,来电 |
| binderror | EventHandle | 当发生错误时触发 error 事件,detail = {errMsg: ‘something wrong’} |
注:
