在功能组件中,我们可以像这样传递道具。
function Country(props){
}
我们可以像这样传递默认道具值
function Country({name:'Sri Lanka',description:'blah! blah!'}){
}
然后我们可以将这样的道具传递给组件。
<Country name={'Germany'} description={'haha...'} />
但我确实想访问道具的历史对象。所以我做了
function Country({name:'Sri lanka',description:'haha',...props}){
}
但是当我console.log props是一个空对象时。在这里我想我可能也想传递props对象。我怎么做?
<Country name={'Germany'} description={'haha...'} />
元芳怎么了
相关分类