1
我试图将文件转换为Blob,但显然我甚至无法将文件转换为Blob的子类。无法将文件转换为Blob
我试过像这样:<Blob>file
和这个:file as Blob
。 和错误总是一样的:
Type 'File' cannot be converted to type 'Blob'. Property 'size' is missing in type 'File'.
我在做什么错?
我试图将文件转换为Blob,但显然我甚至无法将文件转换为Blob的子类。无法将文件转换为Blob
我试过像这样:<Blob>file
和这个:file as Blob
。 和错误总是一样的:
Type 'File' cannot be converted to type 'Blob'. Property 'size' is missing in type 'File'.
我在做什么错?
以下显示完全没有错误。
declare const file: File;
const blob = file as Blob;
确保您的打字稿的版本是最新的(2.3.2是最新的写这篇文章的)
我打消了我的node_modules现在更新到2.3.2和错误持续存在(你用来测试的代码会抛出同样的错误),这可能是我的框架的问题吗?我正在使用Ionic 3(Angular 4)。 – akz92
是在lib.d.ts中声明的文件和文件的类型(定义)? –
我在示例中添加了一个操场链接。你可以看到它的工作原理。 –