当我尝试分配
时let blob:Blob = {blobParts: [content]};
其中content是json。
其中Blob
在lib.d.ts
中声明为
interface Blob {
readonly size: number;
readonly type: string;
msClose(): void;
msDetachStream(): any;
slice(start?: number, end?: number, contentType?: string): Blob;
}
declare var Blob: {
prototype: Blob;
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
};
它给了我以下错误:
Type '{ blobParts: any[]; }' is not assignable to type 'Blob'. Object literal may only specify known properties, and 'blobParts' does not exist in type 'Blob'.
我已多次验证blobParts的拼写
答案 0 :(得分:0)
您应该使用new
关键字...
let blob: Blob = new Blob([content]);