html5-qrcode webpack encore



我尝试使用https://github.com/mebjas/html5-qrcode与webpack

npm i html5-qrcode --save

+ html5-qrcode@2.0.11
added 2 packages from 2 contributors in 8.99s
root@21ce69a5652

/application# yarn run encore dev——watch

import("html5-qrcode");

编译成功,但给出控制台错误

ncaught (in promise) TypeError: Cannot read property 'Html5Qrcode' of undefined
at Object.<anonymous> (html5-qrcode.min.js:6)
at Object../node_modules/html5-qrcode/dist/html5-qrcode.min.js (html5-qrcode.min.js:8)
at __webpack_require__ (bootstrap:84)
at __webpack_require__.t (bootstrap:182)

require('html5-qrcode');

类似于import,但是错误是

Uncaught TypeError: Cannot read property 'Html5Qrcode' of undefined
at Object.<anonymous> (html5-qrcode.min.js:6)
at Object../node_modules/html5-qrcode/dist/html5-qrcode.min.js (html5-qrcode.min.js:8)
at __webpack_require__ (bootstrap:79)
at Module../assets/components/ScannerQrCode.js (ScannerQrCode.js:6)
at __webpack_require__ (bootstrap:79)
at Module../assets/components/Games.js (app.js:374)
at __webpack_require__ (bootstrap:79)
at Module../assets/components/Home.js (app.js:748)
at __webpack_require__ (bootstrap:79)
at Module../assets/app.js (app.js:1)

(作者在这里)这个问题已经在最新版本2.1.0中修复了

  • Github release: mebjas/html5-qrcode/releases/tag/v2.1.0
  • npm - html5-qrcode

请让我知道这是否解决了问题,否则让我知道或直接在GitHub项目上提交问题- mebjas/html5-qrcode

相关内容

  • 没有找到相关文章

最新更新