如何解决react-native-router-flux不能改变背景颜色(附代码)

122 阅读1分钟

我最近升级了我所有的依赖,现在我的应用程序的背景在每个页面上都是永久性的灰色。

我搞不清楚原因,但已将范围缩小到react-native-router-flux ,因为它不能识别过去工作的背景颜色属性。

我试着把它放在各个地方,但这些解决方案都不起作用。

App.js

    return (
    <View style={{
        alignContent: 'center',
        justifyContent: 'center',
        height: Dimensions.get('window').height,
        width: Dimensions.get('window').width,
        backgroundColor: 'pink'
      }}>
      <StatusBar hidden={true} />
      <Provider store={store}>
        <Router sceneStyle={{backgroundColor: 'pink'}} />
      </Provider>
    </View>
)

而在Router.js中

const RouterComponent = () => {
  return (
    <Router sceneStyle={{backgroundColor: 'pink'}}>
      <Scene key="root" duration={0} sceneStyle={{backgroundColor: 'pink'}}>
          <Scene key="main" sceneStyle={{backgroundColor: 'pink', alignItems: 'center', justifyContent: 'center'}} hideNavBar={true}>
            <Scene key="dashboard" component={DashboardContainer} hideNavBar={true} initial sceneStyle={{backgroundColor: 'pink'}} />
          </Scene>
        </Scene>
    </Router>
  )
}

我几乎在文档建议的所有地方都添加了backgroundColor: 'pink'。我有什么不明白的吗?

"react-native-router-flux": "^4.3.1", "react-native": "0.68.2", "react": "17.0.2",

PS.我知道我可以在每个组件上单独设置颜色,但在我更新之前,我可以在整个应用程序中设置背景颜色,而这正是我想要做的。