用的react开发页面,页面切换的时候太快了,感受效果不是很好,网上搜索了不少,发现这个简单方便,效果也还能够,记录一下react
在父组件上添加 className=‘animate-route’this
class Admin extends Component { constructor(props) { super(props); this.state = {}; } render() { return ( <div className='animate-route'> <GlobalStyle /> <Header /> <Content>{this.props.children}</Content> <Footer /> </div> ); } } export default Admin;
CSS添加以下代码spa
.animate-route { animation-duration: 1s; animation-fill-mode: both; animation-name: fadeRoute; } @keyframes fadeRoute { from { opacity: 0; } to { opacity: 1; } }
刷新网页看看把......code