vue:生成二维码 qrcode、vue-qr(二维码中间可带logo)

这篇具有很好参考价值的文章主要介绍了vue:生成二维码 qrcode、vue-qr(二维码中间可带logo)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一、方法一 qrcode

qrcode - npm

1.1、安装

yarn add qrcode

1.2、页面引入

import QRCode from 'qrcode';

1.3、方法里边使用

getQRCodeUrl(){  
    QRCode.toDataURL(
        'hello world',{
          color: {
            dark:"#010599FF",
            light:"#FFBF60FF"
          }
        }
      )
      .then((url) => {
        // 获取到url后即可在页面使用--二维码图片
        console.log('url', url)
      })
      .catch((e) => {
        console.log('e', e)
      });
}

 二维码url:vue:生成二维码 qrcode、vue-qr(二维码中间可带logo)

​​​​​​​ 

1.4、options

名称 类型 默认值 说明
errorCorrectionLevel String M 错误处理级别。可选值:lowmediumquartilehigh or LMQH
maskPattern Number 可选值:01234567
margin Number 4
scale Number 4
width Number
color.dark String #000000ff
color.light String #ffffffff

二、方法二 vue-qr

vue-qr - npm

2.1、安装

yarn add vue-qr

2.2、页面引入

import VueQr from 'vue-qr'

2.3、组件增加vue-qr

components: { VueQr },

2.4、template使用

logoSrc中间logo

<vue-qr style="width:200px;height:200px;" logoSrc="https://image.dandelioncloud.cn//dist/img/NoSlightly.png" text="Hello world!" :size="200"></vue-qr>

 2.5、options

Parameter Explanation
text Contents to encode. 欲编码的内容
correctLevel Correct Level 0-3 容错级别 0-3
size Width as well as the height of the output QR code, includes margin. 尺寸, 长宽一致, 包含外边距
margin Margin to add around the QR code, default 20px. 二维码图像的外边距, 默认 20px
colorDark Color of "true" blocks. Works only when both colorDark and colorLight are set. (BYTE_DTA, BYTE_POS, BYTE_AGN, BYTE_TMG) 实点的颜色
colorLight Color of empty space, or "false" blocks. Works only when both colorDark and colorLight are set. (BYTE_EPT) 空白区的颜色
components Controls the appearances of parts in the QR code. Read section ComponentOptions to learn more. 阅读 ComponentOptions 了解更多信息。
bgSrc Background url to embed in the QR code. 欲嵌入的背景图地址
gifBgSrc Gif background url to embed in the QR code, If gifBackground is set, backgroundImage will be ignored. This option will affects performance. 欲嵌入的背景图 gif 地址,设置后普通的背景图将失效。设置此选项会影响性能
backgroundColor Background color 背景色
backgroundDimming Color mask to add above the background image. Helpful when having problems with decoding. 叠加在背景图上的颜色, 在解码有难度的时有一定帮助
logoSrc Logo url to embed at the center of generated QR code 嵌入至二维码中心的 LOGO 地址
logoScale Value used to scale the logo image. Larger value may result in decode failure. Size of the logo equals to logoScale*(size-2*margin). Default is 0.2. 用于计算 LOGO 大小的值, 过大将导致解码失败, LOGO 尺寸计算公式 logoScale*(size-2*margin), 默认 0.2
logoMargin White margin that appears around the logo image. Default is 0. LOGO 标识周围的空白边框, 默认为0
logoBackgroundColor Logo background color, need set logo margin. Logo 背景色,需要设置 logo margin
logoCornerRadius Radius of the logo's corners.Default is 0 LOGO 标识及其边框的圆角半径, 默认为0
whiteMargin If set to true, a white border will appear around the background image. Default is true. 若设为 true, 背景图外将绘制白色边框
dotScale Value used to scale down the data dots' size. (0 < scale < 1.0) default 1 数据区域点缩小比例,默认为1
autoColor If set to true, the dominant color of backgroundImage will be used as colorDark. Default is true. 若为 true, 背景图的主要颜色将作为实点的颜色, 即 colorDark,默认 true
binarize If set to true, the whole image will be binarized with the given threshold, or default threshold if not specified. Default is false. 若为 true, 图像将被二值化处理, 未指定阈值则使用默认值
binarizeThreshold Threshold used to binarize the whole image. Default is 128. (0 < threshold < 255) 二值化处理的阈值
callback Data URI of the generated QR code will be available here. 生成的二维码 Data URI 可以在回调中取得,第一个参数为二维码 data URL, 第二个参数为 props 传过来的 qid(因为二维码生成是异步的,所以加个 id 用于排序)
bindElement If set to true, the generated QR will bind to a HTML element automatically. Default is true. 指定是否需要自动将生成的二维码绑定到HTML上, 默认是true

三、欢迎交流指正,关注我一起学习文章来源地址https://www.toymoban.com/news/detail-411363.html

到了这里,关于vue:生成二维码 qrcode、vue-qr(二维码中间可带logo)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • vue3 qrcode 生成二维码展示 亲测可用

    网上找的好多vue3 生成二维码代码都不能用,正确办法如下 安装 script template

    2024年02月09日
    浏览(26)
  • 【vue-qrcode + html2canvas】前端二维码生成与下载

    其实一开始搜的时候,很多还都是推荐的 vue-qrcode ,于是就先用这个,但是发现想要在二维码中间放一个自定义的image的时候,这个库有点麻烦,需要自己将 image 图片盖在二维码上面(官方教程也是如此)。好吧,一开始我也这么干了,但是盖完之后,我需要下载这个有居中

    2024年04月17日
    浏览(32)
  • 前端qrcode生成二维码详解

    qrcode 是一个基于JavaScript的二维码生成库,主要是通过获取 DOM 的标签,再通过 HTML5 Canvas 绘制而成,不依赖任何库。 官方文档:https://www.npmjs.com/package/qrcode qrcode理论上支持所有现代浏览器以及部分老版本浏览器。具体而言,只要这些浏览器支持HTML5 Canvas和/或DOM操作,就可以

    2024年02月21日
    浏览(51)
  • 使用jquery.qrcode生成二维码

    1、首先在页面中加入jquery库文件和qrcode插件。 2、在页面中需要显示二维码的地方加入以下代码: 3、生成二维码 qrcode支持canvas和table两种方式进行图片渲染,默认使用canvas方式,效率最高,当然要浏览器支持html5。直接调用如下 也可以通过以下方式调用: 这样就可以在页面

    2024年02月06日
    浏览(32)
  • C# QRCode二维码的解析与生成

    已知一张二维码图片,怎么生成一张一模一样的图片出来? 最近有个项目,需要用到QRCode,之前只做过Datamatrix格式的,想着应该也是差不多的,于是就依葫芦画瓢,掏出我的陈年OnBarcode类库,一通修改,生成了个崭新的QRCode,与客户提供的二维码图片一比对,虽然扫出来内

    2024年02月12日
    浏览(41)
  • 详解Python生成二维码插件QrCode的使用

    二维码(QR Code)是一种常见的矩阵型条码,被广泛用于扫码支付、产品标识、活动推广等领域。Python提供了许多第三方库用于生成和解析二维码,其中最常用的是qrcode库。本文将介绍如何使用qrcode库来生成二维码,并提供相应的代码示例和详细说明。 在开始之前,我们需要

    2024年02月16日
    浏览(38)
  • tki-qrcode插件二维码的生成

    1、全局安装tki-qrcode插件 2、查看下载插件后的版本信息 3、在页面中引入tki-qrcode 4、生成二维码整体代码 5、效果展示 此样式是平时黑色二维码样式,此为打过马赛克的二维码(不打马赛克博客无法展示图片,无奈(O~O) 注: 二维码中的内容可绑定链接和其他内容值 根据自

    2024年02月09日
    浏览(28)
  • Qt + QR-Code-generator 生成二维码

    之前使用 libgrencode 生成二维码,LGPL 协议实在不方便,所以需要找一个 github 星星多的,代码简单最好 header-only,协议最好是 MIT 或者兼容协议而不是 GPL 或者 LPGL。 QR-Code-generator 正好符合这个要求,而且还提供 C / C++ / Java / Python / JS / Rust 等 6 种语言实现,直接把 qrcodegen.hp

    2024年02月15日
    浏览(25)
  • 动态二维码生成器PHP Dynamic QRcode

    什么是 PHP Dynamic QRcode ? PHP Dynamic QRcode 是一个允许生成和保存动态和静态二维码( QR 码)的应用。它具有简洁、响应灵敏且用户友好的设计。其中包含您网站中可能需要的一般功能,如:记录管理( CRUD )、安全身份验证、分页、过滤器。 什么是 Dynamic Qr codes ? Dynamic Qr co

    2024年02月11日
    浏览(57)
  • 微信小程序生成二维码(weapp-qrcode)

    插件 npm 地址:https://www.npmjs.com/package/weapp-qrcode 插件 GitHub 地址:https://github.com/yingye/weapp-qrcode/tree/master 一、引入 1、根据 GitHub 指引将 weapp-qrcode 放到本地 uitl 文件夹下; 2、创建 canvas 3、在 js 文件中引入 weapp-qrcode 以及使用; 这里是添加了 logo 的二维码;相关参数请参考

    2024年02月15日
    浏览(34)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包