我有一个react原生视图,里面有一个Lottie动画,但动画根本没有显示,屏幕只是黄色(封闭视图的背景颜色)。
下面是我的代码:
import React, { Component } from 'react';
import {
StyleSheet,
View,
} from 'react-native';
import LottieView from 'lottie-react-native';
export default class Splash extends Component {
constructor(props) {
super(props);
}
static navigationOptions = {
header: null,
};
render() {
return (
<View style={{flex: 1, backgroundColor: 'yellow'}}>
<LottieView
style={{flex: 1}}
source={require('../check.json')}
autoPlay
loop
/>
</View>
);
}
}发布于 2019-02-15 17:35:53
我试用了您提供的Lottie文件,它确实起作用了。
下面是我在App.js中使用的代码,让它正常工作。
import React, {Component} from 'react';
import {Platform, StyleSheet, View} from 'react-native';
import LottieView from 'lottie-react-native';
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<LottieView
style={{flex: 1}}
source={require('./check.json')} {/* I think your issue is that you have the wrong path for your lottie file*/}
autoPlay
loop
/>
</View>
);
}
}注意:在我的项目中,我的App.js和我的check.json在同一个文件夹中。

这是一张它工作的图片

https://stackoverflow.com/questions/54705445
复制相似问题