1、安装react-animated-router
yarn add react-animated-router
2、引入
import AnimatedRouter from 'react-animated-router';
import 'react-animated-router/animate.css'; //引入默认的动画样式定义
3、在layout中使用
render() {
const { children, location, loading, route } = this.props;
//去除tabbar的其他路由
if (BarRoutes.indexOf(location.pathname) < 0) {
return (
<div style={{ overflowX: 'hidden', height: "100%" }}>
{children}
</div>
)
}
//Tabbar路由
return (
<div style={{ overflowX: 'hidden', height: "100%" }}>
<AnimatedRouter >
<MenuBar pathname={location.pathname}>
{children}
</MenuBar>
</AnimatedRouter>
</div>
);
}