【发布时间】:2022-02-17 14:10:07
【问题描述】:
我参考了https://www.npmjs.com/package/cordova-plugin-qrscanner 并尝试在我的移动应用中创建二维码扫描功能。
所以对于第一步,我在我的 ts 文件中创建以下代码:
function onDone(err, status){
if (err) {
// here we can handle errors and clean up any loose ends.
console.error(err);
}
if (status.authorized) {
// W00t, you have camera access and the scanner is initialized.
// QRscanner.show() should feel very fast.
} else if (status.denied) {
// The video preview will remain black, and scanning is disabled. We can
// try to ask the user to change their mind, but we'll have to send them
// to their device settings with `QRScanner.openSettings()`.
} else {
// we didn't get permission, but we didn't get permanently denied. (On
// Android, a denial isn't permanent unless the user checks the "Don't
// ask again" box.) We can ask again at the next relevant opportunity.
}
}
QRScanner.prepare(onDone);
但是,我在尝试构建时遇到错误。
TS2304:找不到名称“QRScanner”
以下是我的版本:
- Angular CLI:10.2.3
- 节点:10.16.3
- 操作系统:linux x64
- 角度:10.2.5
- npm 版本:6.9.0
我在 package.json 中的 cordova-plugin-qrscanner 版本是:
"@types/cordova-plugin-qrscanner": "^1.0.31",
"cordova-plugin-qrscanner": "^3.0.1",
【问题讨论】:
标签: node.js angular cordova npm plugins