Giter Site home page Giter Site logo

vue-qr's Introduction

vue-qr

Version License

The Vue Component for SumiMakito's Awesome-qr.js. Support Vue2/Vue3/Vite

The only one qr code component for Vue.js you need !

Notice

Not support IE 不支持IE浏览器

Examples, 样例

Try to scan these QR codes below with your smart phone.

Example 1 Example 2 Example 3 Example 4

Demo

Run npm run dev or yarn dev

运行 npm run dev or yarn dev

Installation

install with NPM

npm install vue-qr --save

Import

// vue2.0
import VueQr from 'vue-qr'

// vue3.0 (support vite)
import vueQr from 'vue-qr/src/packages/vue-qr.vue'
...
{
  components: {VueQr}
}

Usage

In template

<vue-qr text="Hello world!"></vue-qr>
<vue-qr :bgSrc='src' :logoSrc="src2" text="Hello world!" :size="200"></vue-qr>
<vue-qr text="Hello world!" :callback="test" qid="testid"></vue-qr>
export default {
    methods:{
        test(dataUrl,id){
            console.log(url, id)
        }
    }
}
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

ComponentOptions

ComponentOptions controls the appearances of parts in the QR code.组件选项控制二维码中零件的外观。

type ComponentOptions = {
  data?: {
    scale?: number;
  };
  timing?: {
    scale?: number;
    protectors?: boolean;
  };
  alignment?: {
    scale?: number;
    protectors?: boolean;
  };
  cornerAlignment?: {
    scale?: number;
    protectors?: boolean;
  };
};
// default ComponentOptions

{
  data: {
    scale: 1,
  },
  timing: {
    scale: 1,
    protectors: false,
  },
  alignment: {
    scale: 1,
    protectors: false,
  },
  cornerAlignment: {
    scale: 1,
    protectors: true,
  },
}

scale 比例尺

Type number?

Scale factor for blocks in the specified area of the QR code. 在 QR 码指定区域的块的比例。

protectors

Type boolean?

Controls whether or not to draw the translucent protectors under the specified area in the QR code.控制是否在 QR 码的指定区域下绘制半透明保护器。

For more details you should definitely check out Awesome-qr.js

vue-qr's People

Contributors

apasov avatar binaryify avatar binaryifytest avatar chenfuqichenfuqi avatar dependabot[bot] avatar uwang avatar vanbolee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-qr's Issues

安装引用后出现 "export 'default' (imported as 'VueQr') was not found in 'vue-qr'是啥原因

WARNING in ./node_modules/babel-loader/lib??ref--1-oneOf-1!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Merchant/Info.vue?vue&type=script&lang=js&
145:25-30 "export 'default' (imported as 'VueQr') was not found in 'vue-qr'
@ ./node_modules/babel-loader/lib??ref--1-oneOf-1!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Merchant/Info.vue?vue&type=script&lang=js&
@ ./src/views/Merchant/Info.vue?vue&type=script&lang=js&
@ ./src/views/Merchant/Info.vue
@ ./src/router.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/only-dev-server ./src/main

dotScale的默认值

v2.0.3版本里面,dotScale的默认值是1,与目前的文档一直。
v2.0.4版本里面,dotScale的默认值改为了0.35。。。但是文档还是显示的1。
希望更新一下文档,并且这个值是跟二维码的样式有关的。

背景问题

怎么设置为默认的黑白色 不要彩色的 像草料 那样

multiple qrcode in single page

when i put two vue-qr components in a single page, it only display the first one,the second on can not seen

<vue-qr text="Hello world!" height="200" width="200"/>
<vue-qr text="Hello world!" height="200" width="200"/>

在ie下有点不兼容

如图,大概就是说data(){} 少了冒号
这个是在vuecli下用的,结果编译后,chrome正常就IE导致 整个页面打不开

33

44

nuxt中使用,uuid为空

nuxt使用uuid是个空的,我测试了下不要再beforeMount中计算,放到mounted中就没有问题

部分安卓手机页面头信息包含MMWEBID的版本,二维码生成不了

"Mozilla/5.0 (Linux; Android 7.0; PRO 7 Plus Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/044408 Mobile Safari/537.36 MMWEBID/9371 MicroMessenger/7.0.3.1400(0x27000336) Process/tools NetType/4G Language/zh_CN" (生成不了)

该情况出现在企业微信的APP下面,正常微信跟浏览器都可以打开

logo跨域问题

image

设置了logoSrc之后出现canvases的跨域问题,有没有好的解决方案

npm vue-qr 报错

D:\Program Files\git-projects\hops-aportal\node_modules\canvas>if not defined npm_config_node_gyp (node "D:\AppData\Roaming\nvm\v8.4.0\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Warning: Missing input files:
C:\GTK\bin\zlib1.dll
C:\GTK\bin\libexpat-1.dll
C:\GTK\bin\libpng14-14.dll
C:\GTK\bin\libcairo-2.dll
C:\GTK\bin\libfontconfig-1.dll
C:\GTK\bin\libfreetype-6.dll
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(54,5): error MSB8020: The build tools for Visual St
udio 2012 (Platform Toolset = 'v110') cannot be found. To build using the v110 build tools, please install Visual Studio 2012 build tools
. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then
selecting "Retarget solution". [D:\Program Files\git-projects\hops-aportal\node_modules\canvas\build\canvas.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (D:\AppData\Roaming\nvm\v8.4.0\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "D:\Program Files\nodejs\node.exe" "D:\AppData\Roaming\nvm\v8.4.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Program Files\git-projects\hops-aportal\node_modules\canvas
gyp ERR! node -v v8.4.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xieke\AppData\Roaming\npm-cache_logs\2017-12-25T03_39_54_805Z-debug.log

部分机型不兼容

iphone6(A1586) 系统 10.0.2 以及部分安卓机型(具体未反馈),无法生成带logo的二维码(开始以为logo太大,但logo缩小为20*20还是无法生成)。

能不能不加polyfill

我的项目内置了polyfill了 编译后发现vue-qr内也有 导致报错
Uncaught Error: only one instance of babel-polyfill is allowed
要求运行环境支持es7就好了啊

webpack使用dll问题

You may need an appropriate loader to handle this file t t thisype. entation abou|
|


|
@ ./node_modules/vue-qr/src/main.js 1:0-32

需要配置额外的.vue解析 ,无法直接引用

报错

awesome-qr提示没安装,安装过后还是报错

在ie下有点不兼容

如图,大概就是说data(){} 少了冒号
这个是在vuecli下用的,结果编译后,chrome正常就IE导致 整个页面打不开

33

44

:bgSrc :logoSrc 两属性直接赋值"http://xxxxx.png"会报跨域问题

Access to Image at 'http://xxx.yyyyyyyy.com/app/package/2ec8bab90c794f208b6c2137a50dd9db.png' from origin 'http://localhost:9527' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9527' is therefore not allowed access.

如果直接使用img标签可以展示出图片
<img src="http://xxx.yyyyyyyy.com/app/package/2ec8bab90c794f208b6c2137a50dd9db.png">

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.