Skip to content

Commit

Permalink
fix: Fixed TypeScript type export error.
Browse files Browse the repository at this point in the history
  • Loading branch information
scopewu committed Aug 5, 2023
1 parent a064346 commit b6c14c4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [3.4.1] - 2023-08-05

### BUGFIX

- Fixed TypeScript type export error.

## [3.4.0] - 2023-04-15

### Performance
Expand Down
16 changes: 16 additions & 0 deletions README-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ createApp({
</script>
```

在 Vue 3 中配合 `TypeScript` 使用:

```html
<template>
<qrcode-vue :value="value" :level="level" :render-as="renderAs" />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import QrcodeVue, { Level, RenderAs } from 'qrcode.vue'
const value = ref<String>('qrcode')
const level = ref<Level>('M')
const renderAs = ref<RenderAs>('svg')
</script>

## Component props

### `value`
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ Or single-file components with a `*.vue` extension:
</script>
```

When you use the component with Vue 3 with `TypeScript`:

```html
<template>
<qrcode-vue :value="value" :level="level" :render-as="renderAs" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import QrcodeVue, { Level, RenderAs } from 'qrcode.vue'
const value = ref('qrcode')
const level = ref<Level>('M')
const renderAs = ref<RenderAs>('svg')
</script>
```

## Component props

### `value`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qrcode.vue",
"version": "3.4.0",
"version": "3.4.1",
"description": "A Vue.js component to generate QRCode.",
"type": "module",
"main": "./dist/qrcode.vue.cjs.js",
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { defineComponent, h, onMounted, onUpdated, PropType, ref } from 'vue'
import QR from './qrcodegen'

type Modules = ReturnType<QR.QrCode['getModules']>
type Level = 'L' | 'M' | 'Q' | 'H'
export type Level = 'L' | 'M' | 'Q' | 'H'
export type RenderAs = 'canvas' | 'svg'

const defaultErrorCorrectLevel = 'H'

Expand Down Expand Up @@ -104,7 +105,7 @@ const QRCodeProps = {
const QRCodeVueProps = {
...QRCodeProps,
renderAs: {
type: String as PropType<'canvas' | 'svg'>,
type: String as PropType<RenderAs>,
required: false,
default: 'canvas',
validator: (as: any) => ['canvas', 'svg'].indexOf(as) > -1,
Expand Down

0 comments on commit b6c14c4

Please sign in to comment.