1 回答
TA贡献1802条经验 获得超4个赞
只要你把数据清除了,自然就会触发动画了.记住一点,我们只要操作数据就好,React会帮我们更新UI.
class ComBox extends Component {
state = {
content: 'ghgsdfs'
}
HideAni = () => {
this.setState({content: ''})
}
render() {
return (
<div>
<button onClick={()=> this.HideAni()}>销毁按钮</button>
<ReactCSSTransitionGroup
transitionName="example"
transitionEnterTimeout={500}
transitionLeaveTimeout={300}
>
{this.state.content ? <p>{this.state.content}</p> : ''}
</ReactCSSTransitionGroup>
</div>
)
}
}
添加回答
举报