57 lines
885 B
JavaScript
57 lines
885 B
JavaScript
import JsBarCode from "jsbarcode";
|
|
import props from "./props";
|
|
const index = {
|
|
name: "EleBarCode",
|
|
props,
|
|
emits: [],
|
|
data() {
|
|
return {
|
|
instance: null
|
|
};
|
|
},
|
|
mounted() {
|
|
this.render();
|
|
},
|
|
methods: {
|
|
render() {
|
|
if (!this.value) {
|
|
return;
|
|
}
|
|
try {
|
|
this.instance = new JsBarCode(
|
|
this.$refs.rootRef,
|
|
this.value,
|
|
this.options
|
|
);
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
}
|
|
},
|
|
watch: {
|
|
value() {
|
|
this.render();
|
|
},
|
|
options: {
|
|
handler() {
|
|
this.render();
|
|
},
|
|
deep: true
|
|
},
|
|
tag() {
|
|
this.$nextTick(() => {
|
|
this.render();
|
|
});
|
|
}
|
|
},
|
|
render(h) {
|
|
return h(this.tag, {
|
|
ref: "rootRef",
|
|
style: { display: this.value ? null : "none" }
|
|
});
|
|
}
|
|
};
|
|
export {
|
|
index as default
|
|
};
|