1

如果这很重要,我正在使用next.js并且我pages/_app.tsx有:

function MyApp({ Component, pageProps }: AppProps) {

    return (
        <PaperProvider theme={customTheme}>

            <View style={{ flex: 1, top: 0, left: 0, height: '100%', width: '100%', zIndex: 10, position: 'absolute', backgroundColor: 'red' }}>
                <Text> Here</Text>
            </View>
        </PaperProvider>
    )
}

export default MyApp

并且customTheme是:

import { DefaultTheme } from 'react-native-paper';

export const customTheme = {
    ...DefaultTheme,
    dark: false,
    colors: {
        ...DefaultTheme.colors,
        primary: '#247BA0',
        accent: '#70C1B3',
        error: '#FF1654',
        disabled: '#F3FFBD',
        placeholder: '#D3EDBE',
    }
}

我看到了Text,但没有红色背景。我错过了什么?

4

1 回答 1

1

好的,这里的问题是使用position: 'absolute'with height: '100%',删除样式对象中的这些属性之一,它应该可以工作。如果您希望全屏将背景颜色更改height: '100%'height: Dimensions.get("window").height

于 2020-05-06T13:55:29.970 回答