如何更改已安装组件中的路由

问题描述 投票:0回答:1

我正在渲染中使用此代码来显示标题。需要移动此逻辑来装入事件。如何实现。

  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
1个回答
0
投票

componentDidMount(){

    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>
             )

}

© www.soinside.com 2019 - 2024. All rights reserved.