在example here、View Source和upload.component.ts中,有以下代码:
public imagePreviews: FileInfo[] = [];
(...)
reader.onload = function (ev) {
const image = {
src: ev.target.result,
uid: file.uid
};
that.imagePreviews.unshift(image);
};如果我使用它,我会得到以下错误:
Argument of type '{ src: any; uid: string; }' is not assignable to parameter of type 'FileInfo'. Property 'name' is missing in type '{ src: any; uid: string; }' but required in type 'FileInfo'.
如果我检查here,我发现src不是FileInfo的一个元素,因此我得到的错误确实是有意义的。然而,我不明白为什么它在他们的网页上起作用,我怎么才能让它起作用。
谢谢!
发布于 2019-06-03 16:00:37
这确实是一个错误。如果你只是简单地改变
imagePreviews: FileInfo[] = [];
使用
imagePreviews = [];
它将正常工作,不会引发任何问题。
即使FileInfo和const image的属性不匹配,image中也不会使用FileInfo的属性,因此程序会按预期运行(尽管有错误)。
https://stackoverflow.com/questions/56151832
复制相似问题