get_qrcode/index.js

const qrcode = require("qrcode");
/**
 * 功能:读取字符,通过第三方组件库进行二维码生成
* @param {string} [url] - 需要生成图片的链接以及URL路径
* @param {function} [thenFun] - 成功的回调函数
* @param {function} [catchFun] - 失败的回调函数
* @returns {undefined} - undefined
 */
 function get_qrcode(
  url = "I am a pony!",
  thenFun = (url) => {
    console.log(url);
  },
  catchFun = (err) => {
    console.error(err);
  }
) {
  qrcode.toDataURL(url).then(thenFun).catch(catchFun);
}
export default get_qrcode