WeChat Applet
Mini Program Development
Let's talk about how to use a small program to generate posters (plug-in recommended)Let's talk about how to use a small program to generate posters (plug-in recommended)
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!

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
[Related learning recommendations: 小program development tutorial]
Step 2:
Introduced into the json file of the page
{
"usingComponents": {
"painter":"/components/painter/painter"
}
}Step 3:
Use the wxml of the page
接收海报的图片容器
<image mode="widthFix" src="{{ posterImg }}" id="goods_qr-code" alt />
<painter wx-if="{{showPainter}}" palette="{{data}}" bind:imgOK="firstImg" />
palette 字段作为画图数据的数据源, 图案数据以 json 形式存在
widthPixels 强制指定生成的图片的像素宽度
绘图完成后,可以通过绑定 imgOK 或 imgErr 事件来获得成功后的图片或失败的原因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
})
},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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Mac version
God-level code editing software (SublimeText3)





