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”)