我已在 Index.html 文件中导入 instascan 库,
<script type="text/javascript" src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js"> </script>
我的 app.component.html 中有如下代码,
<video id="preview"></video>
我的 app.component.ts 中有如下代码,
let scanner = new Instascan.Scanner({
video: document.getElementById('preview'),
mirror: false,
facingMode: { exact: 'environment' }});
Instascan.Camera.getCameras().then(cameras => {
if (cameras.length > 0) {
this.scanner.start(cameras[1]);
} else {
alert("Camera Permission denied");
window.location.reload();
}
}).catch(error => {
console.log(error);
window.location.reload();
})
在Instascan中遇到问题,编译时出现如下错误, 找不到名称“Instascan”。
最佳答案
考虑使用 import
语法而不是使用 link
标记。
首先,安装 Instascan NPM 软件包:
npm i instascan
然后将其导入到您的组件中:
import Instascan from 'instascan';
...
您的其余代码将起作用。
关于angular - Angular 6 中的 Instascan 库面临问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60519805/