NavigationBar的属性约束和默认属性
来源:1-9 自定义组件NavigationBar-3
 
			倚松听花语
2018-11-02
static propTypes = {
    style: View.propTypes.style,
    title: PropTypes.string,
    titleView: PropTypes.element,
    hide: PropTypes.bool,
    statusBar: PropTypes.shape(StatusBarShape),
    rightButton:  PropTypes.element,
    leftButton: PropTypes.element,
}
static defaultProps = {
    statusBar: {
        barStyle: 'light-content',
        hidden: false,
    },
}
老师,为什么这两个对象定义了却没有用到。那属性约束和默认属性设置是怎么起作用的?
写回答
	1回答
- 
				  CrazyCodeBoy 2018-11-05 - 默认属性是在没有为组件设置需要的属性的之后能有个默认值; 
- 属性检查约束是为了在规范组件的属性的使用,能够做个check,发现属性设置的不对有个提示; 
 可参考:https://reactjs.org/docs/react-component.html#class-properties-1 00
相似问题
