如何在 Angular 4 应用程序中使用 TypeScript 中的 FileSystem API?
我添加@types/filesystem
到devDependencies
,但我仍然收到编译错误,例如
“窗口”类型上不存在属性“resolveLocalFileSystemURL”。
找不到名称“文件错误”。
找不到名称“FileEntry”。
我tsconfig.json
的和 angular-cli 生成的几乎一样,我只是添加"node_modules/typed-cordova-plugin-purchase
到typeRoots
:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types",
"node_modules/typed-cordova-plugin-purchase"
],
"lib": [
"es2016",
"dom"
]
}
}
我应该导入任何东西吗?有没有在 Typescript 中使用 FileSystem 的例子?
我最终通过添加types
到tsconfig.json
,实际上tsconfig.app.json
(我正在使用 angular CLI 1.0.1)使它工作
"types": [
"cordova",
"cordova-plugin-file"
]
使用@types/filesystem
是不够的,因为FileError
那里没有定义,这就是我使用"@types/cordova-plugin-file
.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句