React Native Video 在使用样式时抛出“渲染错误 - 对象作为反应子对象无效”

时间:2021-04-18 06:07:37

标签: reactjs react-native

我收到此错误:

<块引用>

对象作为 React 子对象无效(发现:对象带有键 {position、top、left、bottom、right})。如果您打算渲染一组子项,请改用数组。

我只是想播放视频

import React from 'react';
import {
    View, Text, StyleSheet, Dimensions
} from 'react-native';

import Video from 'react-native-video';
// import styles from './styles';


const Post = () => {
    const videoURL = 'https://d8vywknz0hvjw.cloudfront.net/fitenium-media-prod/videos/45fee890-a74f-11ea-8725-311975ea9616/processed_720.mp4'
    return (
        <View >
            <Video source={{ uri: videoURL }}>
                style={styles.backgroundVideo}
                {/* onError={(e) => console.log(e)} */}
                {/* resizeMode={'cover'} */}
            </Video>
        </View>
    );
};

var styles = StyleSheet.create({
    backgroundVideo: {
        position: 'absolute',
        top: 0,
        left: 0,
        bottom: 0,
        right: 0,
    },
});


export default Post;

这与React Native Video Github中的示例相同 我错过了什么?

1 个答案:

答案 0 :(得分:0)

我认为样式应该在视频组件中,像这样:

sparse_categorical_crossentropy