pure-svg-code通过返回svg和imgUrl来生成二维码、条形码
<!--npm下载插件-->
npm install pure-svg-code --save-dev
应用
<img :src="barCode" alt="条形码">
<img :src="qrCode" alt="二维码">
import { barcode, qrcode, svg2url } from 'pure-svg-code';
getBarCode() {
<!--svg-->
const svgString = barcode("1234567890", "code128", {width:'50', barWidth:1, barHeight:50});
<!--imgUrl-->
this.barCode = svg2url(svgString);
},
getQrCode() {
<!--svg-->
const svgString = qrcode({
content: "1234567890",
padding: 0,
width: 100,
height: 100,
color: "#000000",
background: "#ffffff",
ecl: "M"
});
<!--imgUrl-->
this.qrCode = svg2url(svgString);
}
mounted() {
this.getBarCode();
this.getQrCode();
}