在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5/ React-Navigation的嵌套stackNavigator導(dǎo)航組件被覆蓋

React-Navigation的嵌套stackNavigator導(dǎo)航組件被覆蓋

我在寫Android平臺(tái)的,用react-navigator,發(fā)現(xiàn)一直有問(wèn)題。
我想在tabNavigator導(dǎo)航里面嵌套一個(gè)StackNavigator導(dǎo)航,但是StackNavigator的一直顯示不出來(lái),一開始我懷疑是配置出問(wèn)題,于是單獨(dú)寫了個(gè)StackNavigator的例子,發(fā)現(xiàn)是沒(méi)問(wèn)題的。

外層tab導(dǎo)航
clipboard.png

里層的stack導(dǎo)航,里面可以點(diǎn)擊跳轉(zhuǎn)。
clipboard.png

但是我將stack導(dǎo)航放入tab導(dǎo)航作為一部分,卻顯示不正常

<Search />
<Category/>    //stack導(dǎo)航組件

異常:stack組件背景不同,(上面的組件也沒(méi)有設(shè)置背景色)
clipboard.png
再在下面加一個(gè)其他組件,就覆蓋了stack組件

<Search />
<Category/>
<Recommend />  //推薦組件

效果:
clipboard.png

再如果用ScrollView標(biāo)簽包裹,就看不到stack組件了

<ScrollView style={{flex:1}}>
    <Search />
    <Category/>
</ScrollView>

效果:
clipboard.png

下面是stack組件:

class Category extends Component {
  constructor(props) {
    super(props)
    this._onPressButton = this._onPressButton.bind(this)
    this.state = {
    }
  }
  _onPressButton() {
    const { navigate } = this.props.navigation;
    navigate('List', {
      name: `名字列表`
    });
  }
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.text1}>分類</Text>
        <View style={styles.row}>
          <TouchableOpacity onPress={this._onPressButton}>
            <View style={styles.item}><Text>互聯(lián)網(wǎng)</Text></View>
          </TouchableOpacity>
          <TouchableOpacity onPress={this._onPressButton}>
            <View style={styles.item}><Text>散文</Text></View>
          </TouchableOpacity>
        </View>
        <View style={styles.row}>
          <View style={styles.item}><Text>管理</Text></View>
          <View style={styles.item}><Text>內(nèi)容</Text></View>
        </View>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    marginLeft: 10,
    marginRight: 10,
  },
  text1: {
    color: '#5e5e5e',
    marginBottom: 5,
    fontSize: 14
  },
  row: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    marginBottom: 10
  },
  item: {
    height: 51,
    width: (Util.size.width - 30) / 2,
    // flex: 1,
    borderColor: '#f1f1f1',
    borderWidth: 1, //Util.pixel
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 5
  }
})
const Navigator = StackNavigator({
  Category: {
    screen: Category,
    path: 'Category',
    navigationOptions: {
      headerTitle: '這是Category',
    },
  },
  List: {
    screen: List,
    path: 'List',
    navigationOptions: {
      headerTitle: '這是list',
      headerTitleStyle:{
      }
    },

  },
}, {
    navigationOptions: {
      headerBackTitle: null,
      headerTintColor: '#333333',
      showIcon: true,
      swipeEnabled: false,
      animationEnabled: false,
    },
    mode: 'card',
  });
export default Navigator

求大佬幫我看一下。

回答
編輯回答
厭遇

弄好了,原來(lái)是嵌套關(guān)系不對(duì),stackNavigator要作為一個(gè)單獨(dú)組件放在tabNavigator,而不能使普通組件內(nèi)嵌套stackNavigator

2017年9月16日 11:02