更詳細的請查閱官方文檔
https://github.com/lindell/vue-barcode
vue-barcode是JsBarcode的一個簡單包裝。所以在使用時的配置屬性需要在JsBarcode中查看
JsBarcode官方文檔
https://github.com/lindell/JsBarcode
安裝
npm install @xkeshi/vue-barcode vue
引入注冊組件
import VueBarcode from '@xkeshi/vue-barcode';
Vue.component('barcode', VueBarcode);
使用組件
<barcode :value="barcodeValue"> 條形碼顯示失敗時的內容 </barcode>
注意點:value值需要給一個初始值,或者使用v-if在沒有收到參數時不渲染節點,這樣后台就不會報錯
我在工作中用到的配置
<barcode v-if="userlist.diseaseName" :value="userlist.examineNumber" :options="{ widht:100,height:50, background:'rgba(255,255,255,.0)'}"></barcode>
options中使用JsBarcode的屬性,需要注意的是條碼除了黑色,其他的顏色都不能被識別,或快速識別
不馳於空想,不鶩於虛聲
