设置组件的属性值
return (
<User
name="Tom" // 字符串
age={18} // 数值
isActivated={true} // 布尔值
interests={['basketball', 'music']} // 数组
address={{ city: 'Beijing', road: 'BeiWuHuan' }} // 对象
/>
)
const userInfo = {
name: 'Tom',
age: 18,
isActivated: true,
interests: ['basketball', 'music'],
address: { city: 'Beijing', road: 'BeiWuHuan' }
}
return <User {...userInfo} />
夹具