0
有什麼好的沒有bug的StackNavigator例子在DrawerNavigator裏面? 正如在我的示例中,當抽屜打開時,頂部導航標題被隱藏,當我在NewScreen頁面內時,無法打開抽屜(帶有幻燈片)。 所以我想打開標題和任何頁面上的抽屜。 感謝Q:ReactNative StackNavigator裏面的DrawerNavigator
http://image.prntscr.com/image/eb4d869acbcf4d22a08159b072aae930.png
下面是代碼
import React, { Component } from 'react';
import {
AppRegistry,
Button,
Platform,
ScrollView,
StyleSheet,
TouchableHighlight,
Text,
} from 'react-native';
import {
DrawerNavigator,StackNavigator
} from 'react-navigation';
import FontAwesome from "react-native-vector-icons/FontAwesome";
class ScreenHome extends Component{
static navigationOptions = {
title: 'ScreenHome',
};
render() {
const { navigate } = this.props.navigation;
return (
<Button
title="Go to Jane's profile"
onPress={() => navigate('New', { name: 'Jane' })}
/>
);
}
}
class NewScreen extends Component{
static navigationOptions = {
title: 'New screen',
};
render() {
const { navigate } = this.props.navigation;
return (
<Text>Some new screen</Text>
);
}
}
class ScreenRegister extends Component{
static navigationOptions = {
title: 'ScreenRegister',
};
render(){
return <Text>ScreenRegister</Text>
}
}
const MainScreenNavigator = DrawerNavigator({
Recent: {
screen: ScreenHome
},
All: {
screen: ScreenRegister
},
});
export default SimpleApp = StackNavigator({
Home: {
screen: MainScreenNavigator
},
Chat: {
screen: ScreenHome
},
New: {
screen: NewScreen
}
});
AppRegistry.registerComponent('naviTest',() => SimpleApp);
[看起來是個未解決的問題](https://github.com/react-community/react-navigation/issues/165)。您應該查看可能的解決方法的註釋,但在閱讀完所有解決方案後,看起來每個解決方案都存在某種錯誤。 –