提问人:Samik Pandit 提问时间:10/26/2023 最后编辑:Samik Pandit 更新时间:10/27/2023 访问量:28
使用 Lottie React Native 的动画失败
Failed animation using Lottie React Native
问:
我制作了一个订单屏幕,下订单后,我应该会看到一些闪光和拇指动画。但是,没有这样的动画。只能看到“您的订单已收到”文本。
Lottie 版本: “lottie-react-native”: “^6.3.1”
React 原生代码:
import { StyleSheet, Text, SafeAreaView } from "react-native";
import React, { useEffect } from "react";
import LottieView from "lottie-react-native";
import { useNavigation } from "@react-navigation/native";
const OrderScreen = () => {
const navigation = useNavigation();
useEffect(() => {
setTimeout(() => {
navigation.replace("Main");
}, 1300);
}, []);
return (
<SafeAreaView style={{ backgroundColor: "white", flex: 1 }}>
<LottieView
source={require("../assets/thumbs.json")}
//ref={animation}
style={{
height: 260,
width: 300,
alignSelf: "center",
marginTop: 40,
justifyContent: "center",
}}
autoPlay
loop={false}
speed={0.7}
/>
<Text
style={{
marginTop: 20,
fontSize: 19,
fontWeight: "600",
textAlign: "center",
}}
>
Your Order has been recieved
</Text>
<LottieView
source={require("../assets/sparkle.json")}
style={{
height: 300,
position: "absolute",
top: 100,
width: 300,
alignSelf: "center",
}}
autoPlay
loop={false}
speed={0.7}
/>
</SafeAreaView>
);
};
export default OrderScreen;
const styles = StyleSheet.create({});
所有依赖项都已安装,并且目录在资产中得到了适当的维护。lottie json 文件是从 Link 安装的。
答: 暂无答案
评论