在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是传进去的,可能会显示为空,可以使用定时器

posted @ 2021-01-14 11:40  冰晨之露  阅读(791)  评论(0编辑  收藏  举报