为什么动画不工作lottie react native

ibrsph3r  于 2023-01-21  发布在  React
关注(0)|答案(1)|浏览(165)

我遇到了一个问题。我正在使用lottie的一个react原生应用程序,但动画不工作,只有我可以看到图像,但没有动画。有人可以帮助我吗?
资源:https://github.com/lottie-react-native/lottie-react-native代码

<>
      <Formik
        initialValues={{player: ''}}
        validationSchema={Yup.object({
          player: Yup.string()
            .min(3, 'Musth be more 3 letters')
            .max(15, 'must be less than 15 letters')
            .required('Sorry, this field is required'),
        })}
        onSubmit={(values, {resetForm}) => {
          
        }}>
        {({
          handleChange,
          handleBlur,
          handleSubmit,
          values,
          touched,
          errors,
        }) => (
          <>
           .....
          </>
        )}
      </Formik>

      <Modal animationType="slide" transparent={false} visible={visible}>
        <View
          style={{
            height: '100%',
            width: '100%',
            backgroundColor: 'rgba(255,255,255,0.1)',
            alignContent: 'center',
            alignItems: 'center',
            justifyContent: 'center',
          }}>
          <LottieView
            source={require('../assets/loading.json')}
            style={{
              width: 200,
              height: 200,
              alignSelf: 'center',
            }}
            autoPlay
            loop
          />
        </View>
      </Modal>
    </>
oxcyiej7

oxcyiej71#

常数索引:React本币=()=〉{常量批次视图参照=使用参照(空)

return (
    <View style={stylesWithTheme.loadingContainer}>
        <LottieView
            ref={lottieViewRef}
            onLayout={() => lottieViewRef.current?.play()}
            speed={1}
            autoPlay

            loop
            source={loadding} />
    </View>
)

}

相关问题