关于react组件中的constructor和super
正片export default class Child extends React.Component { constructor(props) { super(props); // ... } // ... } 简单来说,react 中通过继承的方式定义 但是如果需要定义实例的 那么 PS: 番外ES7 新的提案有另一种写法,舍去 class MyStatement extends React.Component { state = { text: 'ok' } doSomething = () => { // ... } render() { return <div>{this.state.text}<div> } } 参考react组件中的constructor和super小知识 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |