我遇到了这种奇怪的行为,即render()中的this.props
未定义但在构造函数()中有价值,任何人都可以帮助解释为什么?
class Login extends React.Component {
constructor(props){
super(props); // props is an object
}
render() {
let {loginClick} = this.props // this.props is undefined
let tpl = (<div className="login-box">
</div>)
return tpl
}
}
记录的结果:
{"page":{"status":"1"},"order":{}, function a(){}} // first result
{"page":{"status":"1", "b":{"a":"1"}},"order":{}, function a(){}} // second result