mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +08:00
feat: barcode demo (#252)
This commit is contained in:
10
src/components/ReBarcode/index.ts
Normal file
10
src/components/ReBarcode/index.ts
Normal 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;
|
||||
44
src/components/ReBarcode/src/index.vue
Normal file
44
src/components/ReBarcode/src/index.vue
Normal 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>
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user