一开始简单的将<LottieView>中的source属性进行替换,但替换后动画却处于静止状态,查阅官方例程后得出了一个解决方案。
...
onchange(){
this.animation.play();
}
...
<LottieView
source={this.state.animatesource}
ref={animation => {this.animation = animation;}}
/>
...
- source 更改后,即使有 autoplay={true} ,动画还是禁止的。
- 要使动画动起来,请更新 source 后调用 play() 方法。