mohnuris / qrcode.vue

A Vue.js component to generate qrcode.

Home Page:https://tie.pub/qrcode.vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

qrcode.vue

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

For those using vue-cli you will need to add this option into your vue.config.js file to enable runtime compilation

module.exports = { runtimeCompiler: true }

For those using webpack you will need to set this option in your webpack.config.js file to enable esm bundling.

resolve: {
  alias: {
    vue: 'vue/dist/vue.esm-bundler.js',
  },
},

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

A Vue.js component to generate QRCode.

Build Status 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>

Component props

value

  • Type: string
  • Default: ''

The value content of qrcode

level

  • Type: string
  • Default: H

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

size

  • Type: number
  • Default: 100

The size of qrcode element.

margin

  • Type: number
  • Default: 0

Define how much wide the quiet zone should be.

renderAs

  • Type: string
  • Default: canvas

Generate QRcode as canvas or svg.

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

About

A Vue.js component to generate qrcode.

https://tie.pub/qrcode.vue

License:MIT License


Languages

Language:TypeScript 43.7%Language:JavaScript 22.4%Language:Vue 22.3%Language:HTML 9.8%Language:Shell 1.8%