scopewu/qrcode.vue has 827 GitHub stars and 90 forks. GitHot measured 0 stars in 24 hours and -1 in 7 days. Last checked 2026-11-24 01:41 UTC. Last push 2026-11-19.
計測したスター増加
- 24時間
- 0
- 7日間
- -1
- 15日間
- 履歴を収集中
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
概要
QRCodeを生成するVueコンポーネントです。QRCode vueはVue 2とVue 3の両方に対応し、canvasとSVGの2種類のQRコード形式を利用できます。QRコードのサイズ、余白、誤り訂正レベル、前景色と背景色、ロゴ画像、グラデーション効果をカスタマイズできます。
制作・メディアREADME-ja.md
オリジナルqrcode.vue
⚠️ 現在、Vue 3.xを使用している場合は、qrcode.vue を3.xにアップグレードしてください。
🔒 Vue 2.xを使用している場合は、バージョン 1.x を使用し続けてください。
QRコードを生成するための Vue.js コンポーネントです。Vue 2 と Vue 3 の両方をサポートしています。
インストール
qrcode.vueコンポーネントを Vue.js アプリに使用できます。
npm install --save qrcode.vue # yarn add qrcode.vue
dist/
|--- qrcode.vue.cjs.js // CommonJS
|--- qrcode.vue.esm.js // ESモジュール
|--- qrcode.vue.browser.js // ブラウザまたはrequire.jsまたはCommonJS用のUMD
|--- qrcode.vue.browser.min.js // 最小サイズのUMD
使用方法
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')
または、*.vue 拡張子の単一ファイルコンポーネントで使用します:
<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>
Vue 3で TypeScript を使用する場合:
<template>
<qrcode-vue
:value="value"
:level="level"
:render-as="renderAs"
:background="background"
:foreground="foreground"
:gradient="gradient"
:gradient-type="gradientType"
:gradient-start-color="gradientStartColor"
:gradient-end-color="gradientEndColor"
:image-settings="imageSettings"
:radius="radius"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import QrcodeVue from 'qrcode.vue'
import type { Level, RenderAs, GradientType, ImageSettings } from 'qrcode.vue'
const value = ref('qrcode')
const level = ref<Level>('M')
const renderAs = ref<RenderAs>('svg')
const background = ref('#ffffff')
const foreground = ref('#000000')
const margin = ref(0)
// 画像の設定
const imageSettings = ref<ImageSettings>({
src: 'https://github.com/scopewu.png',
width: 30,
height: 30,
// x: 10,
// y: 10,
excavate: true,
// crossOrigin: 'anonymous', // Set this when you need to export the canvas to an image.
})
// グラデーション
const gradient = ref(false)
const gradientType = ref<GradientType>('linear')
const gradientStartColor = ref('#000000')
const gradientEndColor = ref('#38bdf8')
// 角丸半径
const radius = ref(0)
</script>
コンポーネントプロパティ
value
- タイプ:
string - デフォルト:
''
QRコードの内容。
size
- タイプ:
number - デフォルト:
100
QRコード要素のサイズ。
render-as
- タイプ:
RenderAs('canvas' | 'svg') - デフォルト:
canvas
canvasまたはsvgとしてQRコードを生成します。svgプロパティはSSRで動作します。
margin
- タイプ:
number - デフォルト:
0
静かなゾーンの幅を定義します。
level
- タイプ:
Level('L' | 'M' | 'Q' | 'H') - デフォルト:
H
QRコードの誤り訂正レベル('L'、'M'、'Q'、'H'のいずれか)。詳細については、wikipedia: QR_codeを参照してください。
background
- タイプ:
string - デフォルト:
#ffffff
QRコードの背景色。
foreground
- タイプ:
string - デフォルト:
#000000
QRコードの前景色。
image-settings
- タイプ:
ImageSettings - デフォルト:
{}
Type declaration:
export type ImageSettings = {
src: string // The URL of image.
x?: number // The horizontal offset. When not specified, will center the image.
y?: number // The vertical offset. When not specified, will center the image.
height: number // The height of image
width: number // The height of image
excavate?: boolean // Whether or not to "excavate" the modules around the image.
borderRadius?: number // The border radius of image.
crossOrigin?: 'anonymous' | 'use-credentials' | '' // The CORS attribute for the image. Useful when exporting canvas to an image.
}
The settings to support qrcode image logo.
radius
- タイプ:
number - デフォルト:
0
各QRモジュールの角丸半径。モジュール幅に対する比率で、0 から 0.5 の値を受け入れます。
0(デフォルト)- 正方形モジュール、鋭角0.5- 最大の丸み、モジュールは円形になります
丸みは文脈を認識します:隣接する暗いモジュール間の内角は鋭角のままで、外角のみが丸められます。
<qrcode-vue value="test" :radius="0.35" />
id
- タイプ:
string - デフォルト:
undefined
SVG内部要素(グラデーション、クリップパス)のカスタムID。SSRハイドレーションの一貫性に必要です。useId() を渡して、サーバーとクライアントで一致するIDを生成してください。
<script setup>
// Vue 3.5+ のみ
import { useId } from 'vue'
import { QrcodeSvg } from 'qrcode.vue'
const uid = useId()
// 古いバージョン(3.4以下)
// const uid = 'qrcode-1'
// const uid2 = 'qrcode-2'
</script>
<qrcode-svg value="test" :id="uid" />
省略した場合、モジュールレベルのカウンターが使用されますが、複数リクエストのSSR環境では安全ではありません。
gradient
- タイプ:
boolean - デフォルト:
false
QRコードのグラデーション塗りつぶしを有効にします。
gradient-type
- タイプ:
GradientType('linear' | 'radial') - デフォルト:
linear
グラデーションの種類を指定します。
gradient-start-color
- タイプ:
string - デフォルト:
#000000
グラデーションの開始色。
gradient-end-color
- タイプ:
string - デフォルト:
#ffffff
グラデーションの終了色。
class
- タイプ:
string - デフォルト:
''
QRコード要素のクラス名。
Template Ref Methods (QrcodeCanvas / QrcodeSvg)
QrcodeCanvas と QrcodeSvg の両方がテンプレート ref を介して以下のメソッドを公開しています。QrcodeVue は現在の render-as に応じてこれらを転送します。
QrcodeCanvas
<script setup>
import { ref } from 'vue'
import { QrcodeCanvas } from 'qrcode.vue'
const qrRef = ref()
const handleDownload = () => {
qrRef.value?.download('my-qrcode.png')
}
</script>
<qrcode-canvas ref="qrRef" value="https://example.com" />
| Method | Signature | Description |
|---|---|---|
toDataURL |
(type?: string, quality?: number) => string | undefined |
canvas を Data URL に変換します。 |
download |
(filename?: string) => void |
QR コードの PNG 画像をダウンロードします。 |
CORS 注意: QR コードにクロスオリジンのロゴ画像を含める場合、
imageSettings.crossOrigin: 'anonymous'を設定し、画像サーバーがAccess-Control-Allow-Originヘッダーを返すことを確認してください。そうでない場合、canvas が "tainted" になり、toDataURL/downloadがSecurityErrorをスローします。
QrcodeSvg
<script setup>
import { ref } from 'vue'
import { QrcodeSvg } from 'qrcode.vue'
const qrRef = ref()
const handleDownload = () => {
qrRef.value?.download('my-qrcode.svg')
}
</script>
<qrcode-svg ref="qrRef" value="https://example.com" />
| Method | Signature | Description |
|---|---|---|
toDataURL |
() => string | undefined |
SVG 要素を Data URL に変換します。 |
download |
(filename?: string) => void |
QR コードの SVG 画像をダウンロードします。 |
QrcodeVue 3.5+
QrcodeVue 3.5+ exports separate QrcodeCanvas and QrcodeSvg components, for which the rollup configuration has been modified:
// rollup.config.js
- exports: 'default',
+ exports: 'named',
Direct references to QrcodeVue in common.js and cdn now require the default field:
const QrcodeVue = require('qrcode.vue').default
const { default: QrcodeVue, QrcodeCanvas, QrcodeSvg } = require('qrcode.vue')
<!--With HTML-->
<div id="root">
<p class="flex space-x">
<qrcode-vue :value="test" render-as="svg"></qrcode-vue>
<qrcode-canvas :value="test"></qrcode-canvas>
</p>
<p><input v-model="test" /></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.global.prod.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/qrcode.vue.browser.min.js"></script>
<script>
Vue.createApp({
data() {
return {
test: 'Hello World',
}
},
components: {
QrcodeVue: QrcodeVue.default,
QrcodeCanvas: QrcodeVue.QrcodeCanvas,
},
}).mount('#root')
</script>
AI / LLM サポート
qrcode.vue には、AI コーディングアシスタントがこのライブラリを正しく使うためのリソースが同梱されています:
llms.txt— llmstxt.org 形式の、LLM 向けに要約されたライブラリ概要。skills/qrcode-vue/SKILL.md— Agent Skills 形式のスキルファイル。props 一覧、レシピ、注意点を収録しています。アシスタントのスキルディレクトリ(例:~/.agents/skills/や.claude/skills/)にコピーすると、AI アシスタントが qrcode.vue の使い方を理解できるようになります。
どちらのファイルも npm パッケージに含まれています。
ライセンス
copyright © 2021 @scopewu, license by MIT
関連プロジェクトを探す
読み込み中…