更新记录

1.0(2023-05-31)

init


平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 3.4.8 app-vue app-nvue
钉钉小程序 快手小程序 飞书小程序 京东小程序
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari

ch-canvas

canvas 合成图片 html 转 canvas 分享图片

chCanvas 有两个参数 一个是 canvas 的 id,canvasList 是数组,画布的 z-index 顺序。

chCanvas 方法 是否必填 描述头
id 必填 canvas 的 id
canvasList 必填 一个数组,按数组顺序渲染; [{type:'image'...}]

type=image 以下参数都是必填

{
        type: 'image',
        src: '/static/bg/sky.jpg',
        width: 100,
        height: 100,
        x: 0,
        y: 0,
        isCricle: 0 //图片是否为圆形;
      },

type: 'border' //有圆角的矩形 以下参数都是必填

{
       type: 'border',
       lineColor: '#eee',//线条颜色
       fillColor: '#fff',//背景颜色
       radius: 10,
       rect: {
         width: 100,
         height: 100,
         x: 0,
         y: 0,
       }
     },

type=text 以下参数都是必填

{
        type: 'text',
        class: '.mflex .dec',
        innerHtml: 'xxxxxx',
        color: '#999',
        fontSize: 15,
        width: 100,
         height: 100,
         x: 0,
         y: 0,
      },

type: 'dom' 此类型为 html 转 canvas

{<view
      class="footer"
      id="canvas-container"
      style="
        opacity: 1;
        position: fixed;
        left: 10%;
        right: 10%;
        top: 50px;
        z-index: 2;
        opacity: 0;
      "
    >
     <view class="mflex">
        <image id="ss" src="../../static/logo.png" class="head"> </image>
        <view class="mytext">
          <text class="title">王某某 </text>
          <text class="dec">xxxxxx</text>
        </view>
        <image src="../../static/1.jpg" class="prcode"> </image>
      </view>
      <image src="../../static/1.jpg" class="mb mb1"></image>
    </view>
      },

没有明确标记的都是必填。

  {
        type: 'dom',
        parentId: '#canvas-container',
        chlildren: [{
          type: 'image',
          class: '.mflex>.head',  //唯一性
          src: '/static/logo.png',
          isCricle: 1,
        },
        {
          type: 'text',
          class: '.mflex .title',
          innerHtml: '王某某',
          color: '#000',
          fontSize: 18,
          y: 80,        //选填,若存在属性,优先级高于dom的top位置。
        }, {
          type: 'text',
          class: '.mflex .dec',
          innerHtml: 'xxxxxx',
          color: '#999',
          fontSize: 15,
          y: 100  //选填,若存在属性,优先级高于dom的top位置。
        },
        {
          type: 'image',
          class: '.mflex>.prcode',
          src: '/static/1.jpg',
          isCricle: 0,
        }, {
          type: 'image',
          class: '.mb1',
          src: '/static/1.jpg',
          isCricle: 0,
        }
        ],
      }

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问