VUE生成code128条码
1、先下载插件
npm i jsbarcode
2、生成条码
<template>
<div style="width: 66%;margin: 12px auto 0">
<svg class="tiaoMa"></svg>
</div>
<template/>
<script>
import JsBarcode from 'jsbarcode'
export default {
data() {
return {}
},
mounted() {
this.createdTiaoMa()
},
methods: {
createdTiaoMa() {
let barcode = document.getElementsByClassName('tiaoMa')
JsBarcode(barcode, 'hello world', {
format: "CODE128",
width: 1,
height: 25,
displayValue: true,
text: "要显示的文字",
fontOptions: "bold italic",
font: "PingFangSC-Medium, PingFang SC",
textAlign: "center",
textPosition: "bottom",
textMargin: 5,
fontSize: 13,
background: "transparent",
lineColor: "#000000",
margin: 0,
});
}
}
}
<script/>