当前位置:网站首页>使用 qrcodejs2 生成二维码详细API和参数
使用 qrcodejs2 生成二维码详细API和参数
2022-06-22 18:25:00 【_格鲁特宝宝】
使用 qrcodejs2 生成二维码
安装 qrcodejs2
cnpm install qrcodejs2 --save使用 qrcodejs2
页面引入
import QRCode from 'qrcodejs2'页面标签
<div id="qrcode" ref="qrcode"></div>可以使⽤ id 或者 ref,建议使⽤ ref,因为使⽤ vue 框架控制虚拟 Dom 才是正确的选择简单⽅便
createQRcode(WIDTH, id, text) {
let long = document.documentElement.clientWidth * (WIDTH / 375)
new QRCode(id, {
width: long,
height: long,
text: text,
correctLevel : QRCode.CorrectLevel.L
});
// correctLevel 容错级别,可设置为:
// QRCode.CorrectLevel.L
// QRCode.CorrectLevel.M
// QRCode.CorrectLevel.Q
// QRCode.CorrectLevel.H
// L - M - Q - H 码密度越来越高,默认不设置是用 H
},
// this.createQRcode(132, `qrcode`, `${this.DOMAIN}`);参数说明
new QRCode(element, option)| 名称 | 默认值 | 说明 |
|---|---|---|
| element | - | 显示二维码的元素或该元素的 ID |
| option | 参数配置 |
Options
| 名称 | 默认值 | 说明 |
|---|---|---|
| width | 256 | 图像宽度 |
| height | 256 | 图像高度 |
| typeNumber | 4 | |
| colorDark | "#000000" | 前景色 |
| colorLight | "#ffffff" | 背景色 |
| correctLevel | QRCode.CorrectLevel.L | 容错级别,可设置为: QRCode.CorrectLevel.L QRCode.CorrectLevel.M QRCode.CorrectLevel.Q QRCode.CorrectLevel.H 从上至下生成码密度越来越高 L - M - Q - H |
Events
| 名称 | 说明 |
|---|---|
| makeCode(text) | 设置二维码内容 |
| clear() | 清除二维码。(仅在不支持 Canvas 的浏览器下有效) |
资源
边栏推荐
猜你喜欢

记可视化项目代码设计的心路历程以及理解

NAND闪存(NAND Flash)颗粒SLC,MLC,TLC,QLC的对比

Solution of off grid pin in Altium Designer

NLP-D57-nlp比赛D26&刷题D13&读论文&&找了一个多小时bug

详解openGauss多线程架构启动过程

0816 shortcomings of Feida (improvement direction)

Digital enabling machinery manufacturing industry, supply chain collaborative management system solution helps enterprises upgrade their supply chain

Follow up course supplement of little turtle teacher "take you to learn C and take you to fly"

NRF51822外设学习

Openpnp调试 ------ 0816飞达推0402编带
随机推荐
Shell programming specification and variables
Chapter I 100 hot questions (1-5)
结构型模式之装饰者模式
lua--迭代器、模块、元表
如何在 FlowUs和Notion 等笔记软件中进行任务管理?
Longest common subsequence
Comparison of NAND flash particles SLC, MLC, TLC and QLC
Do you use thread or service?
Input two strings and output the longest substring with the same length
知识蒸馏之Focal and Global Knowledge Distillation for Detectors
Agent model of structured model
Common technical notes
Compilation error: /usr/bin/ld: /usr/local/lib/libgflags a(gflags.cc.o): relocation R_ X86_ 64_ 32S against `. rodata‘
C#,入门教程——关于函数参数ref的一点知识与源程序
Antd tree tree tree selector subclass required
使用 Order by 与 rownum SQL 优化案例一则
1.4-----PCB设计?(电路设计)确定方案
Interface development component devaxpress asp Net core v21.2 - UI component enhancements
Flutter series -flutter route management
Solution of off grid pin in Altium Designer
https://www.npmjs.com/package/qrcodejs2