- 安装:
npm install --save react-lottie
- 使用:
import Lottie from 'react-lottie';
import * as animationData from '../../../public/image/data.json'
export default class LottieControl extends React.Component {
constructor(props) {
super(props);
this.state = {
defaultOptions : {
loop: true,
autoplay: true,
animationData: animationData,
rendererSettings: {
preserveAspectRatio: 'xMidYMid slice'
}
};
}
render() {
return( <div>
<Lottie
options={this.state.defaultOptions}
height={50}
width={50}
isStopped={false}
isPaused={false}/>
</div>)
}
}