在vue中生成条形码
直接看代码吧
首先安装并引入jsbarcode
import JsBarcode from 'jsbarcode'
<img id="barcode" style="margin: 3px;width: 80%;" />
创建方法
getBarCode(id) { JsBarcode('#barcode', id, { format: 'CODE39', lineColor: '#000', background: '#fff', displayValue: false, fontSize: 30, lineColor: '#000' }) },
在mounted中调用,id是传进去的,可能会显示为空,可以使用定时器