此处运用了Lottie动画,请参考https://www.lottiefiles.com/
首先安装 npm i lottie-web
页面中引入
import lottie from 'lottie-web'
import animationData from './data.json'; //这里引入你的动画json文件
代码中写入
componentDidMount() {
lottie.loadAnimation({
container: document.querySelector("#lottie"), // the dom element that will contain the animation
renderer: 'svg',
loop: true,
autoplay: true,
animationData: animationData// the path to the animation json
});
}
render(){
return(
<View id="lottie"></View>
)
}
然后运行页面就能看到动画效果了