Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.put is not a function #364

Open
blueagles opened this issue Jun 11, 2024 · 0 comments
Open

r.put is not a function #364

blueagles opened this issue Jun 11, 2024 · 0 comments

Comments

@blueagles
Copy link

I used vite to build my project

import QRcode from 'qrcode'
QRcode.toDataURL(text.value).then(url => {
    console.log(url)
})

here is the mistake:
TypeError: r.put is not a function
at qrcode.js:240:12
at Array.forEach ()
at createData (qrcode.js:238:12)
at createSymbol (qrcode.js:423:20)
at qrcode$1.create (qrcode.js:497:10)
at browser.js:53:29
at new Promise ()
at renderCanvas (browser.js:51:12)
at r (App.vue:5:1)
at callWithErrorHandling (runtime-core.esm-bundler.js:195:19)

it seems lost the method in bit-buffer.js while build project

BitBuffer.prototype = {

  get: function (index) {
    const bufIndex = Math.floor(index / 8)
    return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
  },

  put: function (num, length) {
    for (let i = 0; i < length; i++) {
      this.putBit(((num >>> (length - i - 1)) & 1) === 1)
    }
  },

  getLengthInBits: function () {
    return this.length
  },

  putBit: function (bit) {
    const bufIndex = Math.floor(this.length / 8)
    if (this.buffer.length <= bufIndex) {
      this.buffer.push(0)
    }

    if (bit) {
      this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))
    }

    this.length++
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant