45 lines
739 B
Vue
45 lines
739 B
Vue
<script>
|
|
import { defineComponent, h } from 'vue';
|
|
import JsBarcode from 'jsbarcode'
|
|
|
|
export default defineComponent({
|
|
name: "VueBarcode",
|
|
props: {
|
|
value: {
|
|
type: String,
|
|
default: undefined,
|
|
},
|
|
options: {
|
|
type: Object,
|
|
default: undefined,
|
|
},
|
|
tag: {
|
|
type: String,
|
|
default: 'canvas',
|
|
},
|
|
},
|
|
watch: {
|
|
$props: {
|
|
deep: true,
|
|
immediate: true,
|
|
handler() {
|
|
if (this.$el) {
|
|
this.generate();
|
|
}
|
|
},
|
|
}
|
|
},
|
|
mounted(){
|
|
this.generate();
|
|
},
|
|
methods: {
|
|
generate() {
|
|
JsBarcode(this.$el, String(this.value), this.options);
|
|
},
|
|
},
|
|
render() {
|
|
return h(this.tag, this.$slots.default);
|
|
},
|
|
});
|
|
</script>
|