Was*_*siF 5 import npm angular angular6
我已经安装了包
npm install local-devices
Run Code Online (Sandbox Code Playgroud)
并将其导入angular.json为
"scripts": [
"./node_modules/local-devices/index.js"
]
Run Code Online (Sandbox Code Playgroud)
并宣布为global variable在src/typings.d.ts
declare let findLocalDevices: any
Run Code Online (Sandbox Code Playgroud)
下面,package文件结构和index.js的local-devices封装
然后尝试在组件中使用它作为
console.log(findLocalDevices())
Run Code Online (Sandbox Code Playgroud)
但有错误
findLocalDevices 未定义
如何导入,请指导!!!
import * as findLocalDevices from 'local-devices'
Run Code Online (Sandbox Code Playgroud)
并在任何方法中将其用作
ngOnInit() {
console.log(findLocalDevices());
}
Run Code Online (Sandbox Code Playgroud)
您可能还需要安装其他软件包 os child_process / mz