【发布时间】:2020-09-24 06:59:47
【问题描述】:
我在渲染中使用此代码来显示标题。需要移动这个逻辑来挂载事件。如何做到这一点。
render() {
const viewPage = this.props.history.location.pathname.includes("/app/accountManagers/view/")
const editPage = this.props.history.location.pathname.includes("/app/accountManagers/edit/")
const newPage = this.props.history.location.pathname.includes("/app/accountManagers/new/")
return (<div >
<div className="app-wrapper">
<ContainerHeader match={this.props.match} title={<IntlMessages id={editPage ? "DIC_ADMIN_SETTINGS_ACCOUNT_MANAGERS_EDIT_MANAGER" : newPage ? "DIC_ADMIN_SETTINGS_ACCOUNT_MANAGERS_NEW_MANAGER" : "DIC_ADMIN_SETTINGS_ACCOUNT_MANAGERS_VIEW_MANAGER"} />} />
</div>
【问题讨论】:
-
你为什么不简单地使用路线而不是匹配位置
-
根据路线需要更改我的索引页面中的标题。所以我使用了这个逻辑
-
所以这个组件没有在上述路径之一上呈现?
标签: javascript reactjs react-redux routes components