微信小程序的canvas画布功能怎么用?canvas画布功能使用教程

时间:2017-04-03404举报小编:zhuxianzhimm

    微信小程序推出以来一直比较受大家欢迎,微信小程序中有一个功能是canvas画布功能,那么这个功能该怎么用呢?下面的教程就是关于微信小程序的canvas画布功能怎么用的,一起来看看吧。

    canvas画布,你可以理解为有一张白布,你可以在画布上画出不同形状、颜色、粗细的图形。

    组件用法:

    微信小程序的canvas画布功能怎么用?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;

    }

    复制代码

    今天的内容就和大家介绍到这里了,想要了解更多精彩内容请继续关注未来软件园每日更新!小编等着你哦!