React项目中使用:(JsBarcode)
import JsBarcode from 'jsbarcode';
componentDidMount(){
this.a();
}
a = () => {
const {dispatch, b} = this.props
dispatch({
type: 'c/d',
payload : {},
}).then(()=>{
JsBarcode(".barcode").init();
this.print()
});
}
/*在render中return*/
render () {
const {l} = this.props
return(
<div className="bd">
<svg className="barcode"
jsbarcode-format="CODE128"
jsbarcode-value={l.val}
jsbarcode-textmargin="0"
jsbarcode-height="55"
jsbarcode-width="1"
jsbarcode-fontsize="10"
>
</svg>
</div>
}
}
HTML中生成条形码:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<script