在本机中获得抽屉导航菜单

问题描述 投票:3回答:1

当我添加所选代码时,它显示未定义的对象(评估'route.routeName')。导航抽屉默认位于左侧。如何在右侧获得它?

import React, { Component } from "react";
import { Platform, StyleSheet, Text, View } from "react-native";
import { DrawerNavigator } from "react-navigation";
import ScreenFirst from "./src/ScreenFirst";
import ScreenTwo from "./src/ScreenTwo";

const DrawerExample = DrawerNavigator(
  {
    ScreenFirst: { screen: ScreenFirst },
    ScreenTwo: { screen: ScreenTwo }
  },
  {
    drawerPosition: "right",
    drawerWidth: 100
  }
);
export default DrawerExample;

enter image description here

react-native react-navigation
1个回答
0
投票

如果您使用的是导航3.x,则需要导入这些人

import {createDrawerNavigator, createAppContainer} from 'react-navigation'

然后尝试这个:

const DrawerExample = DrawerNavigator(
  {
    ScreenFirst: { screen: ScreenFirst },
    ScreenTwo: { screen: ScreenTwo }
  },
  {
    drawerPosition: "right",
    drawerWidth: 100
  }
);

const MyApp = createAppContainer(DrawerExample);
export default MyApp
© www.soinside.com 2019 - 2024. All rights reserved.