felippenardi / lottie-react-web

Lottie Wrapper for React on the web.
MIT License
191 stars 49 forks source link

set animationData error #50

Open mtsee opened 3 years ago

mtsee commented 3 years ago
function LayerComp() {
   const [animdata, setAnimdata] = useState(null);
    useEffect(() => {
       $.getJSON('https://h5ds-cdn.oss-cn-beijing.aliyuncs.com/other/lottie/data.json').done(res => {
                 setAnimdata(res);
       })
    }, [])

   return <>
     {animdata && (
        <Lottie
          options={{
            assetsPath: 'https://h5ds-cdn.oss-cn-beijing.aliyuncs.com/other/lottie/images',
            animationData: animdata,
            speed: 1, // 速度
            autoplay: true,
            renderer: 'svg',
            loop: true
          }}
        />)}
   </>
}

image

hestyle commented 3 years ago

me too +1