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;
}
属性
类型
描述
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组件支持大部分事件类型也支持catch开头非冒泡事件。
canvas组件默认默认宽度300px、高度225px。
一个页面中canvas-id不能重复使用。