diff --git a/src/routes/mobile/IndexMobile.js b/src/routes/mobile/IndexMobile.js index 5bec810..2ff5083 100644 --- a/src/routes/mobile/IndexMobile.js +++ b/src/routes/mobile/IndexMobile.js @@ -1,7 +1,7 @@ import React from "react"; import "antd-mobile-v2/dist/antd-mobile.css"; import { Icon, NavBar, TabBar, Modal } from "antd-mobile-v2"; -// import { history } from 'dva/router'; +// import { routerRedux } from 'dva/router'; import { connect, history } from "umi"; import * as commonUtils from "@/utils/utils"; @@ -46,26 +46,24 @@ class IndexMobile extends React.Component { }; } componentWillMount() { - console.log(this.props,'indexMobile'); - - // this.props.dispatch(history.push("/indexMobile")); // 刷新时更新路由,避免底部按钮和返回按钮错乱显示 - // if (this.props.routing && this.props.routing) { - // const { state } = this.props.routing; - // if (state) { - // const { sId } = state; - // if (sId === "myself") { - // this.setState({ selectedTab: "myself" }); - // // this.renderContent('contacts'); - // } - // } - // } + history.push("/indexMobile"); // 刷新时更新路由,避免底部按钮和返回按钮错乱显示 + if (this.props.routing && this.props.routing) { + const { state } = this.props.routing; + if (state) { + const { sId } = state; + if (sId === "myself") { + this.setState({ selectedTab: "myself" }); + // this.renderContent('contacts'); + } + } + } // AppUtil.addDrag(); } componentDidUpdate(prevProps) { /* eslint-disable */ - if (prevProps?.location.state !== this.props.location.state) { + if (this.props.location && prevProps?.location.state !== this.props.location.state) { const originTitle = { message: "消息", scene: "现场", @@ -285,7 +283,7 @@ class IndexMobile extends React.Component { selectedTab: "message", title: "消息", }); - this.props.dispatch(history.push("/indexMobile")); + history.push("/indexMobile"); }} data-seed="logId" > @@ -322,7 +320,7 @@ class IndexMobile extends React.Component { selectedTab: "scene", title: "现场", }); - this.props.dispatch(history.push("/indexMobile")); + history.push("/indexMobile"); }} data-seed="logId1" > @@ -359,7 +357,7 @@ class IndexMobile extends React.Component { selectedTab: "workbench", title: "工作台", }); - this.props.dispatch(history.push("/indexMobile")); + routerRedux.push("/indexMobile"); }} > {this.state.selectedTab === "workbench" ? this.renderContent(this.state.selectedTab) : ""} @@ -395,7 +393,7 @@ class IndexMobile extends React.Component { selectedTab: "myself", title: "我的", }); - this.props.dispatch(history.push("/indexMobile")); + history.push("/indexMobile"); }} > {this.state.selectedTab === "myself" ? this.renderContent(this.state.selectedTab) : ""}