javascript - 为什么我在 React Native 和 Native Base 中使用 TouchableOpacity 时图标消失了?

标签 javascript reactjs react-native native-base

我正在使用 React Native 和 NativeBase。

我只是尝试在条目旁边显示一个图标,并在触发函数后添加 TouchableOpacity,但图标消失了

这是我的代码:

              <Item floatingLabel>
                  <Label>Password</Label>
                  <Input
                    autoCorrect={false}
                    autoCapitalize='none'
                    secureTextEntry={ this.state.securePass }
                    onChangeText = { value => this.updateInput('password', value)}
                    value = { this.state.form.password.value }  
                    type = { this.state.form.password.type }             
                  />
                   <TouchableOpacity>
                      <Icon name='eye'  type="FontAwesome" style={ styles.iconFont } />
                  </TouchableOpacity>
              </Item>

如果我将此代码放在 nativeBase 的 Item 之外但不在里面:

               <TouchableOpacity>
                  <Icon name='eye'  type="FontAwesome" style={ styles.iconFont } />
              </TouchableOpacity>

希望你能帮到我!

谢谢!!

最佳答案

<View style={{flexDirection: 'row'}}>
<TouchableOpacity>
                      <Icon name='eye'  type="FontAwesome" style={ styles.iconFont } />
                  </TouchableOpacity>    
<Item floatingLabel>
                  <Label>Password</Label>
                  <Input
                    autoCorrect={false}
                    autoCapitalize='none'
                    secureTextEntry={ this.state.securePass }
                    onChangeText = { value => this.updateInput('password', value)}
                    value = { this.state.form.password.value }  
                    type = { this.state.form.password.type }             
                  />

              </Item>
</View>

关于javascript - 为什么我在 React Native 和 Native Base 中使用 TouchableOpacity 时图标消失了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51436220/

相关文章:

javascript - 如何使以下绝对定位的模态始终出现在中心(无论用户滚动到哪里)?

reactjs - 为什么与 Typescript 函数 react 的解构 props 需要传递一个对象?

javascript - 在 native 样式表中使用变量不会识别变量

firebase - 当来自 rnfirebase 的 firestore 包时,数据未存储在 Firestore 中

react-native - React Native 卡片样式

javascript - 显式定义 Controller 参数时,默认模型绑定(bind)程序会崩溃

javascript - 在javascript数组中搜索最接近的下一个值

javascript - TypeScript 说一个字符串是无效的,即使它在联合中?

reactjs - 如何模拟实际上是 Redux 的连接 Action 创建者的 Prop ?

javascript - 如何在 Javascript 中获取一天的开始和结束?