Lottie in react native无法找到图像?

问题描述:

我遵循了原生做出反应洛蒂每一个例子,看着那个有同样的问题一样Lottie animation on Expo的问题,但我已经成功导入导出使用通过Bodymovin到以.json动画阵营本地这里:Lottie in react native无法找到图像?

import React, {Component} from 'react'; 
import Animation from 'lottie-react-native'; 
import { 
    StyleSheet, 
    Text, 
    View, 
    Animated, 
    Easing, 
    ScrollView, 
    RefreshControl, 
    AppRegistry 
} from 'react-native'; 

export default class LottieTest extends Component { 
    componentDidMount() { 
    this.animation.play(); 
    } 
    render() 
    { 
    //console.log(this.); 
    return (
     <View> 
     <Animation 
     ref={animation => { this.animation = animation; }} 
     style={{ 
      width: 500, 
      height: 500 
     }} 
     source={require('./animations/btn1.json')} 
     /> 
     </View> 
    ); 
    } 
} 

我把它在一个视图,所以这不是问题。动画json文件没有找到图像,因此只显示形状(在Aftereffects中转换为形状的矢量)。

我不明白为什么JSON不能找到图像的路径。我的图片文件夹是在同一文件夹中以.json和我已经改变了这里的路径来匹配它从称作类:

,"fr":29.9700012207031,"ip":0,"op":34.0000013848484,"w":861,"h":861,"nm":"button1","ddd":0,"assets":[{"id":"image_0","w":782,"h":782,"u":"../animations/images/","p":"img_0.png"} 

我如何使用作出反应本地和洛蒂导入图像?这里有什么问题?

动画图片应该直接添加到XCode和Android Studio项目中。

所以,你应该有以.json文件在IOS/Android的项目作出反应本地项目和图片资源。