Let's talk about how to use a small program to generate posters (plug-in recommended)

青灯夜游
Release: 2021-09-13 18:36:17
forward
2990 people have browsed it

How to use a small program to generate posters? In this article, I will recommend a poster generation plug-in - painter, and see how to use it to generate posters. I hope it will be helpful to you!

Let's talk about how to use a small program to generate posters (plug-in recommended)

Mini program native code generation poster

First step:

Download the package and place the painter package in the components directory

https://github.com/Kujiale-Mobile/Painter
Copy after login

[Related learning recommendations:小program development tutorial]

Step 2:

Introduced into the json file of the page

{ "usingComponents": { "painter":"/components/painter/painter" } }
Copy after login

Step 3:

Use the wxml of the page

接收海报的图片容器   palette 字段作为画图数据的数据源, 图案数据以 json 形式存在 widthPixels 强制指定生成的图片的像素宽度 绘图完成后,可以通过绑定 imgOK 或 imgErr 事件来获得成功后的图片或失败的原因
Copy after login

Step 4:

Use the js of the page

生成海报的方法(){ this.setData({ template: { width: "750rpx", height: "1500rpx", views: [ { type: 'image', url: 图片路路径, css: { top: '10rpx', left: '10rpx', right: '10rpx', width: '730rpx', height: '1500rpx' } } ] } }) } 海报生成完毕自动调用 firstImg(e) { console.log(e.detail.path); this.setData({ posterImg: e.detail.path }) },
Copy after login

Plug-in introduction and official website:Painter generates posters

https://codechina.csdn.net/mirrors/Kujiale-Mobile/Painter?utm_source=csdn_github_accelerator

Original address: https://juejin.cn/post/6995356720125968398

Author: Huang Yongchao

For more programming-related knowledge, please visit:Programming Video! !

The above is the detailed content of Let's talk about how to use a small program to generate posters (plug-in recommended). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:掘金--黄勇超
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!