【发布时间】:2017-08-31 13:42:26
【问题描述】:
我在更改页面内容时遇到问题。 我已经尝试了很多互联网提示。
要点:打开页面后,我想看到loadDepartment和一个按钮。如果我单击“emp”按钮。整页内容改为loadEmployees。我需要这个而不刷新页面。
componentDidMount() {
return this.initializeContent("hie")
}
initializeContent(choose) {
if(choose == "emp") {
console.log("page choosed:", choose);
return this.loadEmployees();
}
else if(choose == "hie") {
console.log("page choosed:", choose);
return this.loadDepartment();
}
else {
console.log("not found user choice -", choose);
return (<div>There is a problem with loading of hierarchy pagae</div>)
}
}
loadDepartment() {
return (<div>apple</div>)
}
loadEmployees() {
return (<div>orange</div>)
}
render() {
return (<div>
{this.componentDidMount()}
<button className="userReq" data-name="emp" onClick={this.initializeContent.bind(this, "emp")}>blabla</button>
</div>)
}
【问题讨论】:
标签: javascript reactjs