【问题标题】:Can't display leftComponentIcon in NavigationBar无法在导航栏中显示左侧组件图标
【发布时间】:2017-07-22 10:00:56
【问题描述】:

我将 react-native-navigation-bar 添加到我的项目中。我想将左侧图标显示为侧边栏图标。我尝试了这段代码,但没有显示任何内容:

   <NavigationBar
    title={'New Tech'}
    height={80}
    titleColor={'#fff'}
    leftComponent={<Icon name="rocket"/> }
    />

ps:我正在安装 react-native-vector-icons 并通过以下方式导入:

import Icon from 'react-native-vector-icons/FontAwesome';

感谢任何帮助。

【问题讨论】:

  • 你按照配置了吗?喜欢输入这个react-native link
  • 我只是安装 NavigationBar 。
  • 我的意思是,您使用react-native-vector-icons 对吗?你尝试过另一个组件吗?是否显示图标?
  • 是的,它工作正常。我用另一个组件测试它
  • 您尝试将leftComponent 更改为leftButtonIcon 吗?

标签: react-native


【解决方案1】:

这取决于您的导航版本,但它被称为leftheaderLeft(较新的版本是较晚的):

static navigationOptions = ({ navigation }) => ({
    title: `whatever`,
    headerLeft: <Button title="" onPress={() => {/*do something*/}} />,
});

【讨论】:

  • 我认为这与堆栈导航有关?
猜你喜欢
  • 1970-01-01
  • 2016-09-16
  • 1970-01-01
  • 2015-07-09
  • 1970-01-01
  • 1970-01-01
  • 2021-12-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多