Skip to content

[mpvue-promise版本]微信小程序上canvas绘制图片助手,一个json就制作分享朋友圈图片

Notifications You must be signed in to change notification settings

xiaoyunchen/mpvue_canvas_drawer

 
 

Repository files navigation

mpvue_canvas_drawer

Fork自mpvue_canvas_drawer

how to use

# install dependencies
npm install mpvue-canvas-drawer

# 引用注册组件
import canvasdrawer from 'mpvue-canvas-drawer'
<canvasdrawer :width="346" :height="284" ref="pic"/>

# 准备配置数据,绘制canvas
this.$refs.pic.draw(CANVAS_VIEWS)

# 将canvas导出图片到临时文件
let tempPath = await this.$refs.pic.saveToTemp()
console.log('tempPath:', tempPath)

完整示例代码请参考 demo

options

width

canvas宽度,单位px,默认值100

height

canvas高度,单位px,默认值100

方法

draw

开始绘制方法,可由父组件直接调用

参数:需要绘制的配置数据,配置文件参考demo

saveToTemp

保存绘制好的canvas图片到本地临时文件,返回临时文件地址

About

[mpvue-promise版本]微信小程序上canvas绘制图片助手,一个json就制作分享朋友圈图片

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 64.1%
  • Vue 35.4%
  • HTML 0.5%