【问题标题】:How to add icon on right button using react native router flux如何使用反应原生路由器通量在右键上添加图标
【发布时间】:2019-10-16 10:41:54
【问题描述】:

我想使用 react native router Flux 添加一个react-native-vector-icon 来代替标题中的右键

这是我的代码:

<Scene
    onRight={() => Actions.inbox()} 
    rightTitle='Inbox' 
    key='home'
    component={Home} 
    title='Home'
    icon={HomeIcon}
    initial
/> 

如何在此添加react-native-vector-icon

【问题讨论】:

    标签: react-native react-native-router-flux


    【解决方案1】:

    您可以使用“rightTitle”道具代替:

    • 图片的“rightButtonImage”道具
    • 自定义组件的“renderRightButton”属性。

    描述于:https://github.com/aksonov/react-native-router-flux/blob/master/docs/API.md#scene

    【讨论】:

      【解决方案2】:

      知道了,我用renderRightButton解决了。

      示例如下:

      const InboxIcon = () => {
          return (
              <View style={{ marginRight: 10 }} >
                  <TouchableOpacity onPress={() => Actions.inbox()} >
                      <Icon
                          name='comment'
                          type='font-awesome'
                          size={30}
                      />
                  </TouchableOpacity>
              </View>
          );
      };
      

      在场景中我渲染它。像这样,

      <Scene
              renderRightButton={InboxIcon}  
              key='home'
              component={Home} 
              title='Home'
              icon={HomeIcon}
              initial
          />
      
      

      【讨论】:

        猜你喜欢
        • 2017-03-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多