<script setup>
import { ref, onMounted} from 'vue';
import JsBarcode from 'jsbarcode';
const targetCode = ref('test123456');
function crearteBarCode() {
JsBarcode('.canvas', targetCode.value, {
displayValue: false,
height: 58,
});
}
// 组件视图渲染之后 生成条形码
onMounted(()=>{
crearteBarCode()
})
</script>
<template>
<div style="margin-top:20px">
<canvas class="canvas" ></canvas>
</div>
<el-input v-model="targetCode" style="width:250px" />
<el-button @click="crearteBarCode">生成条形码</el-button>
</template>
前端生成条形码(jsbarcode)
最新推荐文章于 2024-08-22 23:21:06 发布