我有这个用于卸载和重新安装元素的代码:
import React, { Component } from 'react';
import './App.css';
import Header from './Header';
import Bottom1 from './Bottom1';
import Bottom2 from './Bottom2';
class App extends Component {
constructor(){
super();
this.state={
playWindow: true
}
this.update = this.update.bind(this);
}
update(){
const newState = this.state.playWindow? false : true;
this.setState({playWindow: newState});
}
render() {
return (
<div className="App">
<Header update={this.update}/>
{this.state.playWindow? <Bottom1/> : <Bottom2/> }
</div>
);
}
}
export default App;
当我执行操作时,组件会被交换。问题是没有过渡,切换很粗糙。如何添加动画,比如一个淡出,然后另一个淡入?