老师,这里的items您在对象中定义为数组,但是TS声明时却是对象数组,这块我不太理解
来源:4-8 【全局数据传递】组件化Context Provider

BigTree_
2021-01-09
interface AppStateValue {
username:string,
shoppingCart:{items:{id:number,name:string}[]}
}
const defaultContextValue:AppStateValue= {
username:"alai",
shoppingCart:{items:[]}
}
items:[] =》TS items:{id:number,name:string}[]
写回答
1回答
-
BigTree_
提问者
2021-01-09
是因为对象数组也是数组的一种么
122021-01-09
相似问题