在练习react的时候,我写了这么一段代码,为什么if else都走了呢
import React from 'react'
class Detail extends React.Component {
render() {
const loginstate=this.props.logininfo.islogin
if(loginstate=='no'){
return (
<div></div>
)
}
else{
return (
<div>
<p>姓名:{ this.props.loginlist.userid}</p>
<p>城市:{ this.props.loginlist.city}</p>
</div>
)
}
}
}
export default Detail
可能是走了两遍 你再render函数中放一个congsole.log 看看是不是