react-lottie:动画不会显示

时间:2020-10-19 14:27:28

标签: reactjs lottie

使用react-lottie版本1.2.3尝试在React Web应用程序中进行动画处理。

它已成功编译,没有任何错误消息,但动画无法从json文件中显示。

我遵循了React Lottie not showing animation not showing (web),建议将animationData: animationData替换为animationData: animationData.default。都尝试过,但是没有用。

有什么想法吗?

import React,{Component} from 'react';
import Lottie from 'react-lottie';
import animationData from './lottie/lottie_page_not_found.json';

class PageNotFound extends Component {
  render(){
    const defaultOptions = {
      loop: true,
      autoplay: true,
      animationData: animationData.default,
      rendererSettings: {
        preserveAspectRatio: "xMidYMid slice"
      }
    };

    return(
      <div>
         <h1 style={{display: 'flex', justifyContent: 'center'}}>Page Not Found</h1>
          <Lottie
            options={defaultOptions}
            height={400}
            width={400}
          />
       </div>
    );
  }
}

export default PageNotFound;

0 个答案:

没有答案