为了账号安全,请及时绑定邮箱和手机立即绑定

react 使用ES6的写法,PropTypes为何不生效?

react 使用ES6的写法,PropTypes为何不生效?

SMILET 2018-12-27 22:18:53
import React from 'react';import ReactDOM from 'react-dom';let data = 123;class MyTitle extends React.Component {    //static propTypes = {    //    title: React.PropTypes.string.isRequired    //};//用这种方式则报错    render() {        return <h1> {this.props.title} </h1>;    }}MyTitle.propTypes = {    title: React.PropTypes.string.isRequired};//验证不生效ReactDOM.render(    <MyTitle title={data}/>,    document.getElementById('example'));
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1254 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号