1、安装 jsbarcode
yarn add jsbarcode
2、使用:
<img id="barcode" />
....
import JsBarcode from "jsbarcode";
...
setQrCode(txt) {
const options = {
format: "CODE39", //选择要使用的条形码类型
lineColor: "#000", //条码颜色
width: 3, //条码之间的距离
height: 100, //条码高度
displayValue: true, 是否在条形码下方显示文字
};
JsBarcode("#barcode", txt, options);
},
setQrCode("123456");
效果: