在反应导航中按字母顺序排序屏幕

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

我想按字母顺序自动订购屏幕。所以我可以在底部添加一个屏幕,而不用担心它在列表中的位置。而且我有一大笔屏幕。

这是我的代码(我删除了一些屏幕,因为有太多,并没有发布我的导入):

export const Root = DrawerNavigator({

  Home: { screen: Home },
  About: { screen: About },
  Administration: { screen: Administration },
  CSF: { screen: CSF },
  Calendar: { screen: Calendar },
  Directory: { screen: Directory },
  HNN: { screen: HNN },
  NHS: {screen: NHS},
  IB: { screen: IB },
  ID: { screen: ID },
  Site: { screen: Site },
  WebStore: { screen: WebStore },


}, {
  // drawer config
  //drawerWidth: 239, //drawer width //auto size for device

  contentComponent: props => <ScrollView><DrawerItems {...props} /></ScrollView>, //scrolling drawer
  //backBehavior: 'none', //currently makes back button do nothing
  drawerPosition: 'right',
  drawerBackgroundColor: 'whitesmoke',
  drawerOpenRoute: 'DrawerOpen', //stuff that prevents errors
  drawerCloseRoute: 'DrawerClose',  //stuff that prevents errors
  drawerToggleRoute: 'DrawerToggle', //stuff that prevents errors
  contentOptions: {
    activeTintColor: '#63461E', //brown active text
    inactiveTintColor: '#7F6D45', //light brown inactive text
    style: {
      marginVertical: 9,

    }
  }
  //end drawer config
});

这甚至可能吗? 我怎样才能做到这一点?

提前致谢

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

这与javascript无关,它只是关于你的代码编辑器如何自动为你做这件事。

对于Visual Studio Code,您可以使用可能适合您的插件Sort JSON Object

按字母顺序对选定JSON对象中的键进行排序。

© www.soinside.com 2019 - 2024. All rights reserved.