当前位置:网站首页>uni-app使用canvas绘制二维码
uni-app使用canvas绘制二维码
2022-06-26 18:49:00 【gblfy】

1. 插件选型
uqrCode
2. 页面部分
template:
<view class="canvas-qrcode-box" style="align-self: center;">
<canvas id="qrcode" canvas-id="qrcode" style="width: 170px;height: 170px;align-self: center;" />
</view>
3.事件部分
<script>
var system = uni.getSystemInfoSync();
import uQRCode from '@/uni_modules/Sansnn-uQRCode/components/uqrcode/common/uqrcode.js'
export default {
data() {
return {
vlogId: "",
// screenHeight: system.screenHeight,
screenHeight: system.safeArea.bottom,
statusBarHeight: system.statusBarHeight
}
},
onReady() {
var vlogId = this.vlogId;
var content = {
type: "vlog",
content: vlogId
};
var contentStr = JSON.stringify(content);
uQRCode.make({
canvasId: 'qrcode',
componentInstance: this,
size: 170,
margin: 10,
text: contentStr,
backgroundColor: '#ffffff',
foregroundColor: '#0f0827',
fileType: 'png',
errorCorrectLevel: uQRCode.errorCorrectLevel.H
})
.then(res => {
})
},
onLoad(params) {
var vlogId = params.vlogId;
this.vlogId = vlogId;
},
methods: {
close() {
uni.navigateBack({
delta: 1,
animationType: "slide-out-bottom"
})
},
}
}
</script>
边栏推荐
- How to create and enforce indexes
- To: Apple CEO Cook: great ideas come from constantly rejecting the status quo
- 成功解决之Jenkins报错:The goal you specified requires a project to execute but there is no POM
- Numpy's Matplotlib
- ISO documents
- stm32和电机开发(直流有刷电机和步进电机)
- redis 基础知识
- ROS的发布消息Publishers和订阅消息Subscribers
- The successfully resolved idea cannot use the log normally after referencing Lombok's @slf4j
- Soft test preparation multimedia system
猜你喜欢
随机推荐
Xlua get button registration click event of ugui
Request method 'POST' not supported
Basic and necessary common plug-ins of vscade
项目实战六:分布式事务-Seata
元宇宙链游开发案例版 NFT元宇宙链游系统开发技术分析
自己创建一个时间拦截器
wm_ Concat() and group_ Concat() function
基于tensorflow的手写数字识别
Project practice 6: distributed transaction Seata
LeetCode 128最长连续序列
品达通用权限系统(Day 3~Day 4)
ROS的发布消息Publishers和订阅消息Subscribers
wm_concat()和group_concat()函数
[kubernetes] kubernetes principle analysis and practical application (under update)
Insert string B into string A. how many insertion methods can make the new string a palindrome string
Why don't I recommend going to sap training institution for training?
Project practice 4: user login and token access verification (reids+jwt)
几种常见的UML关系图汇总
转:苹果CEO库克:伟大的想法来自不断拒绝接受现状
Redis单点登陆系统+投票系统










