angular - typescript 中的文件系统

标签 angular typescript html5-filesystem

如何在 Angular 4 应用程序中使用 TypeScript 中的 FileSystem API?

我将 @types/filesystem 添加到 devDependencies,但我仍然收到类似

的编译错误

Property 'resolveLocalFileSystemURL' does not exist on type 'Window'.

Cannot find name 'FileError'.

Cannot find name '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.

关于angular - typescript 中的文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43693819/

相关文章:

typescript - Vue 3 检测不到对在 Vue 组件外部创建的对象所做的更改

javascript - Typescript 和 webstorm,缺少 --module 标志

javascript - Blob 数据位于何处?

javascript - Chrome 文件系统 API 是否仅适用于 Chrome 应用程序(来自 Chrome 网上应用店)?

angular - 如何在 Angular CLI 应用程序中禁用 CSS 中的 URL 解析

angular - 标识符 'required' 未定义。 '__type' 不包含这样的成员

javascript - 尽管导入,但属性过滤器不适用于 Observable<any> 类型

javascript - 为什么这个文件系统 api requestQuota 调用失败?

javascript - WebStorm 无法识别某些 Angular 组件 - mat-toolbar 未知元素

javascript - 将大括号中的数组转换为方括号中的数组