标头在抽屉式导航器中不起作用

时间:2018-10-22 12:26:23

标签: javascript react-native

嗨,我正在使用以下软件包

    {
  "name": "awesome",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@babel/runtime": "^7.0.0",
    "@expo/vector-icons": "^8.0.0",
    "@types/expo__vector-icons": "^6.2.3",
    "native-base": "^2.8.1",
    "react": "16.5.0",
    "react-dom": "^16.5.0",
    "react-native": "0.57.1",
    "react-native-form": "^2.1.3",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-vector-icons": "^6.0.0",
    "react-navigation": "^2.0.0-rc.1",
    "react-select": "^2.1.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.46.0",
    "react-test-renderer": "16.5.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  }
}

enter image description here

在抽屉式导航器中,我有2个屏幕,其中的页眉:每个屏幕都不起作用。我尝试了不同版本的反应导航,但是没有得到输出。我将其与“反应导航”一起使用时得到了它:“ ^ 1.0.0-beta.11”,但是它已经过时了。请原谅我这是一个愚蠢的问题。预先感谢

Home.js

import React, { Component } from "react";
import { Text, View } from "react-native";
import { createDrawerNavigator } from "react-navigation";
import Home from "./Dashboard";
import Setting from "./Setting";

const AppDrawerNavigator = new createDrawerNavigator({
Home: { screen: Home },
Tasks: { screen: Setting }
});

export default AppDrawerNavigator;

Setting.js

import React, { Component } from "react";
import { Text, View } from "react-native";
import { Button, Container, Header, Content, Left } from "native- 
base";
import Icon from "react-native-vector-icons/Feather";
import styles from "../style";

export default class Setting extends Component {
  static navigationOptions = ({ navigation }) => ({
    header: "none"
  });
  render() {
    return (
      <Container>
        <Header>
          <Left>
            <Icon
              style={{ right: 110 }}
              size={40}
              name="menu"
              onPress={() => this.props.navigation.openDrawer()}
            />
          </Left>
        </Header>
        <View style={styles.backgroundContainer}>
          <View style={styles.logoContainer}>
            <Text style={styles.logoText}>Planning</Text>
          </View>
          <View />
        </View>
      </Container>
    );
  }
}

dashboard.js

    import React, { Component } from "react";
    import { Text, View, TextInput, Button, Picker } from "react-native";
    import { Container, Header, Content, Left } from "native-base";
    import Icon from "react-native-vector-icons/Feather";
    import styles from "../style";

    export default class Dashboard extends Component {
      state = { user: "" };
      updateUser = user => {
        this.setState({ user: user });
      };
      static navigationOptions = {
        header: "none"
      };
      render() {
        return (
          <Container>
            <Header>
              <Left>
                <Icon
                  style={{ right: 110 }}
                  size={40}
                  name="menu"
                  onPress={() => this.props.navigation.openDrawer()}
                />
              </Left>
            </Header>
            <View style={styles.backgroundContainer}>
              <View style={styles.logoContainer}>
                <Text style={styles.logoText}>Lead Capture</Text>
              </View>
              <View>
                <View>
                  <Picker
                    selectedValue={this.state.user}
                    onValueChange={this.updateUser}
                    style={{ height: 50, width: 200 }}
                  >
                    <Picker.Item
                      label="franchise partners"
                      value="franchise partners"
                    />
                    <Picker.Item label="distributors" value="distributors" />
                    <Picker.Item label="schools" value="schools" />
                    <Picker.Item label="stem partners" value="stem partners" />
                    <Picker.Item label="parents" value="parents" />
                  </Picker>
                </View>
              </View>
            </View>
          </Container>
        );
      }
    }

1 个答案:

答案 0 :(得分:1)

尝试这样的方法,可以帮助您的标题。

static navigationOptions = {
    header: null,
};