【问题标题】:html5-qrcode webpack encorehtml5-qrcode webpack 安可
【发布时间】:2021-08-20 08:59:28
【问题描述】:

我尝试使用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

在js文件中

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');

类似导入,但错误是

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)

【问题讨论】:

  • 你可以尝试使用 yarn 来安装而不是 npm 吗? yarn add html5-qrcode 然后yarn install

标签: symfony webpack qr-code webpack-encore


【解决方案1】:

(作者在此)已在最新版本2.1.0中修复此问题@

如果这能解决问题,请告诉我,否则请直接告诉我或在 GitHub 项目上提交问题 - mebjas/html5-qrcode

【讨论】:

    猜你喜欢
    • 2022-11-07
    • 2019-06-05
    • 2012-07-28
    • 2022-08-07
    • 2022-12-16
    • 1970-01-01
    • 2019-06-15
    • 1970-01-01
    • 2022-06-29
    相关资源
    最近更新 更多