当前位置 : 主页 > 网络编程 > JavaScript >

propTypes 验证

来源:互联网 收集:自由互联 发布时间:2021-06-28
gistfile1.txt /** * Created by Administrator on 2017/11/10. */import PropTypes from 'prop-types'class Greeting extends React.Component{ render(){ return( {this.props.name} ) }}Greeting.propTypes = { name:PropTypes.string}又比如;BodyIndex
gistfile1.txt
/**
 * Created by Administrator on 2017/11/10.
 */
import PropTypes from 'prop-types'
class Greeting extends React.Component{
    render(){
        return(
            

{this.props.name}

) } } Greeting.propTypes = { name:PropTypes.string } 又比如; BodyIndex.propTypes = { userId:React.PropTypes.number.isRequired }
上一篇:定义样式style
下一篇:ES6 拓展运算符
网友评论