更新记录

1.0.3(2023-04-11)

优化微信小程序端生成海报的清晰度

1.0.2(2023-03-29)

兼容vue2

1.0.1(2023-01-11)

新增绘制图片设置圆角,文字设置对齐方式

查看更多

平台兼容性

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

c-canvas

  • c-design 海报绘制组件

c-design交流群号:330647926

示例预览

https://cloud.vuedata.wang/cdesign/#/pages/canvas/canvas

一、使用示例

<template>
    <view>
        <c-canvas ref="cCanvas" @drawSuccess='thumb=$event' :drawData='drawData' :width='375' :height='475'></c-canvas>
        <image :src="thumb" mode="widthFix" style="width: 100%;"></image>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                thumb:'',
                canvasId:'myCanvas',
                width:375,height:475,
                drawData:[{
                    type: 'image',
                    x: 0,
                    y: 0,
                    value: 'https://mp-eeab6da6-80cd-4e80-844a-66b2a7203834.cdn.bspapp.com/cloudstorage/f5c141ce-472b-4ce7-8886-2028ca631e0c.png',
                    width:375,height:475
                },{
                    type: 'image',
                    x: 0,
                    y: 0,
                    value: 'https://mp-eeab6da6-80cd-4e80-844a-66b2a7203834.cdn.bspapp.com/cloudstorage/f6bd3c29-d452-423e-a4a6-1728b9c2b074.jpeg',
                    width:375,height:375,
                    radius:10
                },
                {
                    type: 'text',
                    x: 10,
                    y: 400,
                    value: '22新款M2Apple/苹果 MacBook Air 13 英寸 MacBook Air笔记本电脑',
                    color: '#262626',
                    font:'normal 400 14px sans-serif',
                    lineHeight:20,
                    lineMaxWidth:250,
                    lineNum:2
                },
                {
                    type: 'image',
                    x: 280,
                    y: 385,
                    value: 'https://mp-eeab6da6-80cd-4e80-844a-66b2a7203834.cdn.bspapp.com/cloudstorage/7dca3f02-baef-470d-88d2-eebd7c31ab73.jpg',
                    width:80,height:80
                },
                {
                    type: 'text',
                    x: 10,
                    y: 450,
                    value: '¥ 9999.00',
                    color: '#f44',
                    font:'normal 400 24px sans-serif',
                    lineHeight:20,
                    lineMaxWidth:200,
                    lineNum:2
                },]
            };
        },
        onReady() {
        }
    }
</script>

<style lang="scss"></style>

二、属性介绍

字段 类型 必填 默认值 描述
canvasId String myCanvas 画布id
isAuto Boolean true 是否自动绘制
width Number 375 画布宽度
height Number 375 画布高度
drawData Array [] 绘制数据 见下方描述

drawData 字段描述

字段 描述
type image 图片 text 文本
x 元素在画布x轴上的位置 原点为画布左上角
y 元素在画布y轴上的位置 原点为画布左上角
value 需要绘制的内容 type=image 为图片地址 type=text 为文本
width 图片宽度 type=image 有效
height 图片高度 type=image 有效
radius 图片圆角 type=image 有效
color 文字颜色 type=text 有效
font 文字样式 示例:'normal 400 14px sans-serif' type=text 有效
lineHeight 文字行高 type=text 有效
lineMaxWidth 文字最大可绘制宽度 type=text 有效
lineNum 文字行数 超出显示省略号 type=text 有效
textAlign 文字对齐方式 可选值 left center right

三、Event

字段 描述
drawSuccess 海报绘制成功事件 返回导出的图片路径

四、Methods

字段 描述
draw isAuto=false时通过ref调用draw()方法可手动绘制

隐私、权限声明

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

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

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

许可协议

MIT协议

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