| | |
| | | |
| | | <script lang="ts" setup> |
| | | |
| | | import { ref, onMounted, nextTick } from 'vue' |
| | | import { ref, onMounted, watch, nextTick } from 'vue' |
| | | import JsBarcode from 'jsbarcode' |
| | | |
| | | defineOptions({ name: 'Barcode' }) |
| | |
| | | value: String |
| | | }); |
| | | |
| | | onMounted(() => { |
| | | nextTick(() => { |
| | | const generateBarcode = () => { |
| | | JsBarcode('.barcode', String(props.value), { |
| | | format: "CODE39",//选择要使用的条形码类型 |
| | | width:1,//设置条之间的宽度 |
| | |
| | | // lineColor:"#2196f3",//设置条和文本的颜色。 |
| | | margin:15//设置条形码周围的空白边距 |
| | | }); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | nextTick(() => generateBarcode()) |
| | | }) |
| | | }) |
| | | |
| | | watch(() => props.value, generateBarcode); |
| | | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |