为什么动画不起作用 洛蒂反应原生



我有一个问题。我在react native应用中使用lottie,但动画不起作用,我只能看到图像,但看不到动画。有人能帮我吗?

资源: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>
</>

const Index: React。FC = () =>{const lottieViewRef = useRef(null)

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

}

最新更新