如何解决 Uncaught Type error $().barcode is not a function

How to resolve Uncaught Type error $().barcode is not a function

Uncaught TypeError: jQuery(...).barcode 不是一个函数 在 codeBars (bookingAdd.php:152) 在 Object.success (bookingAdd.php:141) 着火了 (VM88 jquery-1.10.2.js:3048) 在 Object.fireWith [as resolveWith] (VM88 jquery-1.10.2.js:3160) 完成时 (VM88 jquery-1.10.2.js:8235) 在 XMLHttpRequest.callback (VM88 jquery-1.10.2.js:8778) 代码条@ bookingAdd.php:152 成功@ bookingAdd.php:141 开火@ jquery-1.10.2.js:3048 fireWith @ jquery-1.10.2.js:3160 完成@ jquery-1.10.2.js:8235 回调@ jquery-1.10.2.js:8778 XMLHttpRequest.send(异步) 发送@jquery-1.10.2.js:8706 ajax@jquery-1.10.2.js:8136 bookingSlipAjax @ bookingAdd.php:99 (匿名)@ bookingAdd.php:782

检查 jquery-barcode.js 是否链接正确,然后检查打印代码的方式。

示例 -

        <?php $barcode = "152294018467"; ?>
        <link href="/assets/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
        <script src="/assets/js/jquery-3.2.1.min.js"></script>
        <script type="text/javascript" src="/assets/js/jquery-barcode.js"></script>
        <script>
            $(document).ready(function () {
                $('.barcode-block').barcode("<?php echo $barcode; ?>", "ean13");
            });
        </script>

        <div class="barcode-block"></div>