react-antd-admin icon indicating copy to clipboard operation
react-antd-admin copied to clipboard

点击菜单跳转路由,页面的生命周期函数会执行两次,已找到解决方法,希望开发者补充

Open hellovveb opened this issue 5 years ago • 9 comments

路由跳转动画引起的,MainContent.js 组件中 的Switch组件需要添加location

hellovveb avatar Apr 10 '20 09:04 hellovveb

请问如何修改?我直接在switch上加上了location=true,结果跳转都到了error页面

liangfenggithub avatar Apr 18 '20 09:04 liangfenggithub

在Switch组件中增加location={location}即可。

junchaohu avatar Jun 12 '20 10:06 junchaohu

在Switch组件中增加location={location}即可。

谢谢,具体方式为: <Switch location={location}>

liangfenggithub avatar Jul 14 '20 06:07 liangfenggithub

location={location}后跳转页面会带上上一个页面的部分

aaa123123999 avatar Jul 16 '20 03:07 aaa123123999

知道了 可以吧CSSTransition这个组件去掉

aaa123123999 avatar Jul 16 '20 03:07 aaa123123999

知道了 可以吧CSSTransition这个组件去掉

说得对,这整个content的动画 用处也不大,不过我是增加的location

junchaohu avatar Jul 16 '20 03:07 junchaohu

在Switch组件中增加location={location}即可。

谢谢,具体方式为:

<TransitionGroup>
			<CSSTransition classNames="fade" key={location.pathname} timeout={500}>
				<Content style={{ padding: '15px' }}>
					<Switch location={location}>
						{routes.map(ele => handleFilter(ele.permission) && <Route render={() => <ele.component />} key={ele.path} path={ele.path} />)}
						<Redirect from="/" exact to="/dashboard" />
						<Redirect to="/error/404" />
					</Switch>
				</Content>
			</CSSTransition>
		</TransitionGroup>

junchaohu avatar Jul 16 '20 03:07 junchaohu

感谢大佬,这问题困惑我很久了

peng201015 avatar Jul 30 '20 01:07 peng201015

还是大佬多啊 到处找问题 感谢

githubfengbozhang avatar Sep 07 '20 07:09 githubfengbozhang