|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <svg id="barcode" :style="computeStyle"/>
|
|
|
+ <svg :id="barcodeId" :style="computeStyle"/>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
@@ -27,14 +27,13 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- barcodeWidth: this.style.width + 'px',
|
|
|
- barcodeHeight: this.style.height + 'px',
|
|
|
+ barcodeId: 'barcode'
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
this.createBarcode(this.config)
|
|
|
this.$nextTick(() => {
|
|
|
- const barcode = document.getElementById('barcode');
|
|
|
+ const barcode = document.getElementById(this.barcodeId);
|
|
|
barcode.style.width = `${this.style.width}px`;
|
|
|
barcode.style.height = `${this.style.height}px`;
|
|
|
})
|
|
@@ -46,7 +45,8 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
createBarcode(config) {
|
|
|
- JsBarcode("#barcode", this.value, {
|
|
|
+ const barcode = document.getElementById(this.barcodeId);
|
|
|
+ JsBarcode(barcode, this.value, {
|
|
|
...config,
|
|
|
});
|
|
|
}
|