lindell / JsBarcode

Barcode generation library written in JavaScript that works in both the browser and on Node.js
http://lindell.me/JsBarcode
MIT License
5.45k stars 1.1k forks source link

more than 1 call to JsBarcode errors api.options(...)[options.format] is not a function #400

Open EcotechBrad opened 2 years ago

EcotechBrad commented 2 years ago
      var upc=new Image()
      new JsBarcode(
        upc,
        "796030114977",
        {
          format: "UPC",
          width: 3,
          height: 80,
        }
      )
      var cno=new Image()
      new JsBarcode(
        cno,
        "796030114977",
        {
          format: "UPC",
          width: 3,
          height: 80,
        }
      )

on the second call i get

runtime-core.esm-bundler.js?5c40:218 Uncaught TypeError: api.options(...)[options.format] is not a function
    at JsBarcode (JsBarcode.js?62c5:76)
    ...
EcotechBrad commented 2 years ago
      var upc=new Image()
      JsBarcode(
        upc,
        "796030114977",
        {
          format: "UPC",
          width: 3,
          height: 80,
        }
      )

      var bc=()=>{
      var cno=new Image()
      JsBarcode(
        cno,
        "796030114977",
        {
          format: "UPC",
          width: 3,
          height: 80,
        }
      )
      };
      bc()

does not throw the error