最近有遇到小程序需要展示二维码的需求,我使用的vue2+uniapp的开发环境。因为小程序有包的大小限制,所以不能使用npm下载,需要下载文件下来,直接放到公共文件里面展示。
好的,下来就要看使用流程,
下载文件
先下载qrcode的lib
地址:https://download.csdn.net/download/qq_43185384/86543462
大概内容为
// Core code comes from https://github.com/davidshimjs/qrcodejs
var QRCode;
(function () {
/**
* Get the type by string length
*
* @private
* @param {String} sText
* @param {Number} nCorrectLevel
* @return {Number} type
*/
function _getTypeNumber(sText, nCorrectLevel) {
var nType = 1;
var length = _getUTF8Length(sText);
for (var i = 0, len = QRCodeLimitLength.l