React(为组件设置默认属性值)
2017-10-18 本文已影响31人
余生筑
defaultProps
class App extends Component {
render() {
let on="hello evryone";
return (
<div>
{this.props.name}
</div>
);
}
}
App.defaultProps={
name:"jack"
}
static defaultProps
static defaultProps={
name:"jack"
}
render() {
return (
<div>
{this.props.name}
</div>
);
}
}