Skip to content

youfeed/youloge.qrcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Youloge.Qrcode 纯二维码生成库

vite v4.5.0 building for production...
 1 modules transformed.
dist/youloge.qrcode.es.js  20.41 kB  gzip: 5.45 kB
dist/youloge.qrcode.umd.js  14.39 kB  gzip: 4.84 kB
 built in 171ms

超级小 仅不到5Kb 大小,异步返回一个canvas 对象:只要二维码

  • 💡 组件库有作用域前缀youloge
  • ⚡️ 建议直接引入CDN 即可使用 14.39 kB │ gzip: 4.84 kB
  • 🛠️ https://unpkg.com/youloge.qrcode
  • 📦 https://cdn.jsdelivr.net/npm/youloge.qrcode
  • 🔩 调用 youloge.qrcode(TEXT)
  • 🔑
youloge.qrcode('TEXT',options={}).then(canvas=>{
  document.body.appendChild(canvas)
}).catch(err=>{
  console.log(err)
})

options 可选参数

{
  text: '',
  width: 256,
  height: 256,
  typeNumber: -1,
  background: "#ffffff",
  foreground: "#000000",
}

增加一个生成img.src 示例

youloge.qrcode(qrcode).then(canvas=>{
  canvas.toBlob((blob)=>{
    var file = new Blob([blob], {type: "image/png;charset=utf-8"});
    var src = URL.createObjectURL(file);
    document.querySelector("img").src = src
  },"image/png", 0.95)
})

~ 就这!