wxa-plugin-canvas基础教程
GitHub:https://github.com/jasondu/wxa-plugin-canvas
简介描述:小程序海报组件
wxa-plugin-canvas小程序海报组件-生成朋友圈分享海报并生成图片
概述
wxa-plugin-canvas是一个生成二维码海报的组件,通过非常简单的配置就可以生成精美的海报
安装
方式一.通过 npm 安装 (推荐)
小程序已经支持使用 npm 安装第三方包
# npm
npm i wxa-plugin-canvas -S --production
# yarn
yarn add wxa-plugin-canvas --production
方式二.下载代码
直接通过 git 下载 wxa-plugin-canvas 源代码,并将miniprogram_dist目录拷贝到自己的项目组件目录中
使用组件
{ "usingComponents": { "poster": "wxa-plugin-canvas/poster", } }
接着就可以在 wxml 中直接使用组件
<poster id="poster" config="{{posterConfig}}" bind:success="onPosterSuccess" bind:fail="onPosterFail"> <button>点击生成海报</button> </poster>
使用注意事项
- 图片的域名务必添加到downloadFile合法域名中(开发设置-服务器域名-downloadFile合法域名)
- 如果要使用异步生成海报的方法,务必组件要加上 id=”poster”