feat: barcode demo (#252)

This commit is contained in:
一万
2022-04-25 17:17:21 +08:00
committed by GitHub
parent 0d4499c187
commit afe056649b
9 changed files with 138 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import { App } from "vue";
import reBarcode from "./src/index.vue";
export const ReBarcode = Object.assign(reBarcode, {
install(app: App) {
app.component(reBarcode.name, reBarcode);
}
});
export default ReBarcode;

View File

@@ -0,0 +1,44 @@
<script lang="ts">
export default {
name: "ReBarcode"
};
</script>
<script setup lang="ts">
import JsBarcode from "jsbarcode";
import { ref, onMounted } from "vue";
const props = defineProps({
tag: {
type: String,
default: "canvas"
},
text: {
type: String,
default: null
},
// 完整配置 https://github.com/lindell/JsBarcode/wiki/Options
options: {
type: Object,
default() {
return {};
}
},
// type 相当于 options.format如果 type 和 options.format 同时存在type 值优先;
type: {
type: String,
default: "CODE128"
}
});
const wrapEl = ref(null);
onMounted(() => {
const opt = { ...props.options, format: props.type };
JsBarcode(wrapEl.value, props.text, opt);
});
</script>
<template>
<component :is="tag" ref="wrapEl" />
</template>

View File

@@ -1,3 +1,9 @@
<script lang="ts">
export default {
name: "ReCard"
};
</script>
<script setup lang="ts">
import { computed, PropType } from "vue";
import shopIcon from "/@/assets/svg/shop.svg?component";