微信小程序中生成二维码

时间:2020-05-06 18:14:39   收藏:0   阅读:88

使用weapp-qrcode.js

链接:https://pan.baidu.com/s/1j0qjoYvl6pCK8EzSsfks9g 提取码:8wxe

<canvas class="canvas-code" canvas-id="myQrcode" :style="{ width: qrcode_w + ‘px‘, height: qrcode_w + ‘px‘ }" />

import QRCode from ‘../../utils/weapp-qrcode.js‘;

getEwm() {
			const W = wx.getSystemInfoSync().windowWidth;
			const rate = 750.0 / W;
			// 160rpx 在6s上为 80px
			this.qrcode_w = 160 / rate;
			new QRCode(‘myQrcode‘, {
				text: ‘你的链接‘,
				width: this.qrcode_w,
				height: this.qrcode_w,
				colorDark: ‘#000000‘,
				colorLight: ‘#ffffff‘,
				padding: 2, // 生成二维码四周自动留边宽度,不传入默认为0
				correctLevel: QRCode.CorrectLevel.L, // 二维码可辨识度
				callback: res => {
					console.log(res.path);
				}
			});
		}

  

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!