JsBarcode 选项不适用于 jQuery

JsBarcode options does not work with jQuery

我正在使用 jQuery 生成条形码并尝试添加尺寸选项,但它不起作用。 https://codepen.io/lindell/pen/mPvLXx?editors=1010 上的演示对我不起作用,因为我使用 php 循环遍历项目,然后仅再次循环生成条形码。

<!DOCTYPE html>
<html>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="stylesheet" href="https://www.ssms.anrcorporation.com/assets/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <script src="https://www.ssms.anrcorporation.com/assets/bower_components/jquery/dist/jquery.min.js"></script>
  <script src="https://unpkg.com/jsbarcode@latest/dist/JsBarcode.all.min.js">
  </script>
</head>
<body>

<div class="container bg-white">
    <?php if(!empty($items)){ foreach($items as $row){ ?>
        <svg id="<?= $row['sn']; ?>"></svg>
    <?php }} ?>
</div>

<script>
$(document).ready(function(){
    const items = <?= !empty($items) ? json_encode($items) : json_encode([]); ?>;
    if(items){
        items.map(item => {
            $(`#${item.sn}`).JsBarcode(`SSN : ${item.sn}`)
            .options({font: "OCR-B", height: 25, width: 35})
            .render();
        })
    }
})
</script>

<script src="https://www.ssms.anrcorporation.com/assets/bower_components/jquery-ui/jquery-ui.min.js"></script>
<script src="https://www.ssms.anrcorporation.com/assets/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>

您的问题不清楚,但如果您指的是 fontSizeheightwidth 等大小,请尝试这样的操作:

$(`#barcode1`).JsBarcode(`SSN : 12341234`, {fontSize: 6, height: 20, width: 1, font: "OCR-B"});