将LottieView放入react-native-pages

时间:2018-07-24 12:00:01

标签: react-native lottie react-native-pages

import React, { Component } from 'react';
import { View } from 'react-native';
import { Pages } from 'react-native-pages';
import LottieView from 'lottie-react-native';

class Animation extends Component {
    componentDidMount() {
        this.animation.play();
    }

    render() {
        return (
            <Pages>
                <View>
                    <LottieView
                        style={{ height: 400, width: 400 }}
                        ref={animation => {
                            this.animation = animation;
                        }}
                        source={require('../first.json')}
                    />
                </View>
            </Pages>
        );
    }
}

export default Animation;

当我将LottieView放在<Pages>标记中时,它返回TypeError错误:undefined不是对象(评估“ this.animation.play”)

0 个答案:

没有答案