1.0.4 • Published 2 years ago
qrcodeliaowei v1.0.4
QRCodeliaowei.js
QRCodeliaowei.js 是用于制作二维码的 javascript 库。QRCodeliaowei.js 支持 HTML5 Canvas 和 DOM 中的 table 标签的跨浏览器。QRCodeliaowei.js 没有依赖项。
基本用法
<div id="qrcode"></div>
<script type="text/javascript">
new QRCode(document.getElementById("qrcode"), "http://jindo.dev.naver.com/collie");
</script>
vue
引入页面:
import QRCode from 'qrcodeliaowei'
页面标签:
<div id="qrcode" ref="qrcode"></div>
methods:
creatQrCode() {
this.$refs.qrcode.innerHTML = ''; //清除二维码方法一
let text = 'xxxx';
var qrcode = new QRCode(this.$refs.qrcode, {
text: text, //页面地址 ,如果页面需要参数传递请注意哈希模式#
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: QRCode.CorrectLevel.H,
})
qrcode.clear(); // 清除二维码方法二
}
如果想使用vue vant组件中写h5
只需要在元素#qrcode样式中设置高宽即可
#qrcode{
width:200px;
height:200px;
}
二维码会根据元素#qrcode自适应
配置
var qrcode = new QRCode("test", {
text: "http://jindo.dev.naver.com/collie",
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
你可以使用一些方法
qrcode.clear(); // clear the code.
qrcode.makeCode("http://naver.com"); // make another code.
浏览器兼容性
IE6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC.