微信小程序中生成二維碼


使用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);
				}
			});
		}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM