Giter VIP home page Giter VIP logo

qrcode.vue's Introduction

qrcode.vue

⚠️ Now when you are using Vue 3.x, please upgrade qrcode.vue to 3.x

🔒 if you are using Vue 2.x, please keep using version 1.x;

A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3.

GitHub license

中文

install

the qrcode.vue component can use in you Vue.js app.

npm install --save qrcode.vue # yarn add qrcode.vue
dist/
|--- qrcode.vue.cjs.js         // CommonJS
|--- qrcode.vue.esm.js         // ES module
|--- qrcode.vue.browser.js     // UMD for browser or require.js or CommonJS
|--- qrcode.vue.browser.min.js // UMD Minimum size

Usage

e.g.

import { createApp } from 'vue'
import QrcodeVue from 'qrcode.vue'

createApp({
  data: {
    value: 'https://example.com',
  },
  template: '<qrcode-vue :value="value"></qrcode-vue>',
  components: {
    QrcodeVue,
  },
}).mount('#root')

Or single-file components with a *.vue extension:

<template>
  <qrcode-vue :value="value" :size="size" level="H" />
</template>
<script>
  import QrcodeVue from 'qrcode.vue'

  export default {
    data() {
      return {
        value: 'https://example.com',
        size: 300,
      }
    },
    components: {
      QrcodeVue,
    },
  }
</script>

When you use the component with Vue 3 with TypeScript:

<template>
  <qrcode-vue :value="value" :level="level" :render-as="renderAs" />
</template>
<script setup lang="ts">
  import { ref } from 'vue'
  import QrcodeVue from 'qrcode.vue'
  import type { Level, RenderAs } from 'qrcode.vue'

  const value = ref('qrcode')
  const level = ref<Level>('M')
  const renderAs = ref<RenderAs>('svg')
</script>

Component props

value

  • Type: string
  • Default: ''

The value content of qrcode.

size

  • Type: number
  • Default: 100

The size of qrcode element.

render-as

  • Type: RenderAs('canvas' | 'svg')
  • Default: canvas

Generate QRcode as canvas or svg. The prop svg can work on SSR.

margin

  • Type: number
  • Default: 0

Define how much wide the quiet zone should be.

level

  • Type: Level('L' | 'M' | 'Q' | 'H')
  • Default: H

qrcode Error correction level (one of 'L', 'M', 'Q', 'H'). Know more, wikipedia: QR_code.

background

  • Type: string
  • Default: #ffffff

The background color of qrcode.

foreground

  • Type: string
  • Default: #000000

The foreground color of qrcode.

class

  • Type: string
  • Default: ''

The class name of qrcode element.

License

copyright © 2021 @scopewu, license by MIT

qrcode.vue's People

Contributors

codymikol avatar dependabot[bot] avatar scopewu 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

qrcode.vue's Issues

Single File componet: Vue is not defined

Good afternoon.

Whenever we attempt to integrate QrcodeVue into a single-file component, we receive the error "Vue is not defined". We're certainly not veterans of VueJS, but we have been able to create custom components and get them to work. below is our attempt at the SFC implementation:

`

<script> import QrcodeVue from 'qrcode.vue' export default { data() { return { value: 'https://example.com', size: 300, } }, components: { QrcodeVue, }, } </script>

`

We are using Vue 3.X. We have a "components" directory with the code above. We have made the changes to "vue.config.js" as instructed, and we don't have a "webpack .config.js", but rather an "intellij.config.js" (added the resolve clause here), and when attempting to integrate with Ionic Vue "ionic.config.js (did not add resolve clause here) and babl.config.js (did not add resolve clause here). any help would be greatly appreciated. Thanks.

尺寸设置不一致

设置的尺寸与显示的尺寸不一致
private sizes:any= 320; // 二维码尺寸
private bgColor:any = '#fff'; // 二维码背景色
private fgColor:any = '#000'; // 二维码码条颜色
private http:string = '';// 生成的二维码网址、

vue3 vite

报错 : /node_modules/.vite/deps/qrcode__vue.js 504 (Gateway Timeout)
版本:"qrcode.vue": "^3.3.4"
引入:import QrcodeVue from 'qrcode.vue'

Error decoding QR code


Screenshot 2021-03-19 at 1 53 43 PM

The following code gets "error decoding", tried to scan with IOS, Android and an online reader

Vue parameter for value issue

Hi, again,

I just realized that when I try to use the Vue parameter as value, instead of hardcoded text I am getting an error. I even tried to set a condition to make sure that the element doesn't load if the value is not set, however it seems the library is having an issue. Not sure how to proceed:
image
image
If I return to a simple string error goes away:
image

I tried using computed property, data linked to computed and data with a deep watch on it, but nothing worked.
Any ideas are appreciated!

Thanks!

Vue 2.6.14 and qrcode.vue 1.7.0 Unknown custom element:

Hi! I'm trying to use your Library but got an error
Unknown custom element: <qrcode-vue> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Hover, I made
import QrcodeVue from 'qrcode.vue';
and

export default {
  name: "MyComponnent",
  comments:{
    QrcodeVue
  },.....

in my Component.

I even also tried adding to main.js

import QrcodeVue from "qrcode.vue";

Vue.use(router, QrcodeVue)

What I did do wrong?

package.json

...
  "dependencies": {
    "axios": "^0.27.2",
    "core-js": "^3.8.3",
    "qrcode.vue": "^1.7.0",
    "vue": "^2.6.14",
    "vue-axios": "^3.4.1",
    "vue-router": "^3.5.4",
    "vuetify": "^2.6.0",
    "vuex": "^3.6.2",
    "vuex-persistedstate": "^3.2.1"
  },
....

renderAs props is not working after deployments

First of all, thank you to make this awesome qrcode plugin.

I need to render QRCODE as svg using renderAs props. It works fine on localhost. but it does not work after deployment. I look up the issue. After deployments renderAs props is not on props list it's on attr . I have attached my local & develop screenshots below.

0101
0102

feature: 支持以 img 标签形式展示

场景:

微信页面长按识别二维码

存在问题

当前组件只支持生成 canvas 和 svg,然而微信只支持 img 标签长按识别

希望解决方案

希望该组件支持 img 标签展示

vue3 使用报警,二维码显示不出来

报警信息:Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.
备注:在defineComponent里注册的组件

微信小程序报错 canvas.getContext is not a function

VM649 WAService.js:2 Unhandled promise rejection TypeError: canvas.getContext is not a function
at generate (qrcode.vue.browser.js:1439)
at callWithErrorHandling (runtime-core.esm-bundler.js:154)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:163)
at Array.hook.__weh.hook.__weh (runtime-core.esm-bundler.js:1953)
at flushPostFlushCbs (runtime-core.esm-bundler.js:355)
at flushJobs (runtime-core.esm-bundler.js:391)
at VM649 WAService.js:2
at n (VM649 WAService.js:2)(env: macOS,mp,1.05.2109101; lib: 2.19.6)

Export type `Level`.

Currently the type Level is not exported, thus there will be a type error in TypeScript.

E.g.:

<template>
    <qrcode-vue  :level="level" />
</template>    

<script setup lang="ts">
import QrcodeVue from "qrcode.vue";
const level = ref("H");
</script>

Got: Type 'string' is not assignable to type 'Level | undefined'..

vue 2.7 qrcode1.7版本,异步渲染时,无法显示二维码

// 异步加载模板内容
      const certificateComponents = await Promise.all([
        import('../preview/index.vue')
      ]);

      // 生成证书内容
      const certificates = await Promise.all(
        dataList.map(async (data, index) => {
          const CertificateComponent = certificateComponents[0].default;
          const vueInstance = new Vue({
            render: (h) => h(CertificateComponent, {
              props: {
                certContent: data.certContent,
                backImg: data.certContent.certTpl,
                isSingle: false
              }
            }),
          });

    

          return vueInstance.$mount().$el.outerHTML;
        })
      );

      // 生成证书图片并添加到 ZIP 文件中
      for (let i = 0; i < certificates.length; i++) {
        const certificate = certificates[i];
        const div = document.createElement('div');
        // div.style.position = 'absolute';
        // div.style.top = '-1000px';
        div.innerHTML = certificate;

        // 将虚拟 DOM 元素添加到实际的页面 DOM 中
        document.body.appendChild(div);

通过上面的代码,可以实现异步渲染'../preview/index.vue页面,但是这个页面里面有个二维码组件,无法渲染出现,如果用常规的默认渲染页面方法,非异步渲染,是正常显示二维码的

[MACOS][MOJAVE] - Error: EISDIR: illegal operation on a directory, read

For a unkwon reason, when we try to run the build, the following error is occorring.

---Steps to reproduce---
1 - yarn or npm install to install all dependecies
2 - yarn or npm run build (vue-cli-service-build)

----End steps--------
----Error log below------

ERROR Error: EISDIR: illegal operation on a directory, read
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (fs.js:493:3)
at tryReadSync (fs.js:332:20)
at Object.readFileSync (fs.js:369:19)
at Purgecss.extractFileSelector (/Users/iuripires/Desktop/trade-app-one-frontend/node_modules/purgecss/lib/purgecss.js:673:32)
at Purgecss.purge (/Users/iuripires/Desktop/trade-app-one-frontend/node_modules/purgecss/lib/purgecss.js:443:35)
at /Users/iuripires/Desktop/trade-app-one-frontend/node_modules/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js:282:33
at Array.forEach ()
at /Users/iuripires/Desktop/trade-app-one-frontend/node_modules/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js:247:23
at Array.forEach ()
at PurgecssPlugin.runPluginHook (/Users/iuripires/Desktop/trade-app-one-frontend/node_modules/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js:235:26)
at /Users/iuripires/Desktop/trade-app-one-frontend/node_modules/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js:219:18
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/iuripires/Desktop/trade-app-one-frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), :9:1)
at AsyncSeriesHook.lazyCompileHook (/Users/iuripires/Desktop/trade-app-one-frontend/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeTree.callAsync.err (/Users/iuripires/Desktop/trade-app-one-frontend/node_modules/webpack/lib/Compilation.js:1405:32)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/iuripires/Desktop/trade-app-one-frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (/Users/iuripires/Desktop/trade-app-one-frontend/node_modules/tapable/lib/Hook.js:154:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

-----End of error log------

-----Package JSON------
{
"name": "trade-app-one",
"version": "1.0.1",
"description": "Proposal: All needs from retail in one app",
"author": "TradeUp Group Team",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"test": "vue-cli-service test:unit",
"test:unit": "vue-cli-service test:unit",
"test:watch": "vue-cli-service test:unit --watch",
"test:clear": "vue-cli-service test:unit --clearCache"
},
"husky": {
"hooks": {
"pre-push": "npm run lint && npm run test:unit"
}
},
"dependencies": {
"@babel/polyfill": "7.4.4",
"@babel/runtime": "7.5.5",
"card-validator": "6.2.0",
"highcharts": "7.1.3",
"moment": "2.24.0",
"pdfjs-dist": "2.1.266",
"powerbi-client": "2.10.2",
"printd": "1.4.0",
"qrcode.vue": "^1.7.0",
"quagga": "0.12.1",
"raven-js": "3.27.2",
"register-service-worker": "1.6.2",
"svgxuse": "1.2.6",
"sweetalert2": "7.33.1",
"tao-design-system": "0.7.1",
"tinycolor2": "1.4.1",
"vue": "2.6.10",
"vue-highcharts": "0.1.0",
"vue-i18n": "8.14.0",
"vue-router": "3.1.3",
"vue-slicksort": "1.1.3",
"vue-the-mask": "0.11.1",
"vue2-highcharts": "1.2.5",
"vuex": "3.1.1"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "7.6.0",
"@types/jest": "24.0.18",
"@vue/cli-plugin-babel": "3.11.0",
"@vue/cli-plugin-eslint": "3.11.0",
"@vue/cli-plugin-pwa": "3.11.0",
"@vue/cli-plugin-unit-jest": "3.11.0",
"@vue/cli-service": "3.11.0",
"@vue/eslint-config-standard": "4.0.0",
"@vue/test-utils": "1.0.0-beta.29",
"autodll-webpack-plugin": "0.4.2",
"autoprefixer": "9.6.1",
"axios": "0.19.0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "23.6.0",
"cache-loader": "4.1.0",
"eslint-plugin-jest": "22.17.0",
"glob-all": "3.1.0",
"husky": "3.0.4",
"node-sass": "4.12.0",
"normalize.css": "8.0.1",
"purgecss-webpack-plugin": "1.5.0",
"reset-css": "4.0.1",
"sass-loader": "7.3.1",
"stylelint": "11.0.0",
"stylelint-config-recommended-scss": "3.3.0",
"stylelint-scss": "3.11.0",
"vue-cli-plugin-webpack-bundle-analyzer": "1.4.0",
"vue-eslint-parser": "5.0.0",
"vue-template-compiler": "2.6.10",
"worker-loader": "2.0.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
}
}

----End package JSON------

Ps: Normal usage of the component following the documentation.

Support for Nuxt

Getting error when using with nuxt js

Uncaught TypeError: vue.defineComponent is not a function

firefox 火狐下打印预览二维码显示黑块

火狐浏览器,打印预览,二维码部分显示成了黑块
复现的话可以使用官方的这个页面,测试火狐为最新版本,系统为windows10
https://qr-vue.tie.pub/ 默认示例即可
我调了一下,把 d="M0,0 h25v25H0z" 修改为 d="M0,0 h25v25z" 就能正常显示,对SVG不了解。
希望作者可以帮忙看看

屏幕截图 2023-08-23 094346

Download Image

Hi 👋,
I am using the version 1.7 for Vue 2.

I would like to provide the page with a button that allows to download the generated QR.

Ideally (since the page contains multiple QR code) would be awesome if the same button allows to download more then one at the same time.

How would that be possible? (If it is possible?)

Thanks in advance for your help and thanks for your great work!!

defineComponent

I keep having this error
Uncaught TypeError: vue.defineComponent is not a function
coming from this file
qrcode.vue.browser.js

I am using the single file .vue component method

What am i missing?

Not Vue3 compliant?

Hi @scopewu

When trying to use qrcode-vue in a Vue3 project I get the following error
Uncaught (in promise) TypeError: createElement is not a function
Other vue components having the same error say it is because they are not vue3 compliant.

Export image

Hi, quick questions - is there a way I can export the image to use into PDF generator for example?

Thanks!

dist/qrcode.vue.browser.js after installing 1.7.0

Hi, I'm using Vue 2.3.3. I used npm to install qrcode.vue 1.7.0. Using import QrcodeVue from 'qrcode.vue' within a component results in this:

Module build failed: Error: ENOENT: no such file or directory, open '/Users/path_to_app/node_modules/qrcode.vue/dist/qrcode.vue.browser.js'

Sure enough, all that exists there is

  • qrcode.vue.esm.js
  • qrcode.vue.js
  • qrcode.vue.min.js

How can I get the build process to create the right file? Or is there something else I need to do? Thank you!

Can the width be string?

i have put

size="100vw"

This works perfectly, but i get a warning error. Can this warning be removed?

qrcode generated bug

qrcode generated bug

some url can't be open by scan the qrcode generated by the mobile phone

  1. demo bug

image

Is there any way to download the QR as an image?

First, congratulations to you for your bookstore, it fulfills its objective very well.

My question is: is there any way to download the QR as an image?
I would like to add a button that, when clicked, downloads the same QR code but as an image.

Thank you very much.

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.