我有这个setProd Hooks
export interface faceProduct {
readonly title: string;
readonly prodState: string;
readonly shipping: string;
readonly sold: string;
readonly alt: string;
readonly material: string;
readonly location: string;
readonly src: string[];
readonly color: string[];
readonly saiz: string[];
readonly price: string;
}
export interface faceProductList extends faceProduct {
readonly id: string;
readonly to: string;
}
const [prod, setProd] = useState<faceProductList>({});
我希望初始值是空的object.but,我得到了错误。
const [prod, setProd] = useState<faceProductList>(Object);
每件事都与它相关联的东西一起工作。
发布于 2019-06-10 07:39:35
因为你的打字脚本“这些属性必须被定义”,也就是不把"?“在接口键上,却又没有定义它们的矛盾之处。
您不能拥有所需的所有密钥。而不是去实现它们。
希望这能让我知道你是否需要更多的信息。
https://stackoverflow.com/questions/56519104
复制相似问题