Files
zhibo/node_modules/ele-admin/es/ele-bar-code/index.js
T
xiaoyu 5488f5f0a2 init
2023-05-22 14:07:59 +08:00

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
};