javascript - react native : Unable to change color of text within <TextInput> component

标签 javascript reactjs react-native

我不确定为什么,但是在使用 <TextInput> 时组件 我无法使用标准 style={{color: '#HEX'}} 更改输入文本的颜色.

这是一个例子:

          <TextInput
            style={{
              backgroundColor: 'transparent',
              color: '#fff',
              borderBottomWidth: 0,
            }}
            keyboardAppearance={'dark'}
            keyboardType={'numeric'}
            selectionColor='#fff'
            underlineColor="rgba(0,0,0,0)"
            underlineColorAndroid="rgba(0,0,0,0)"

            placeholderTextColor="#fff"

          />

还有一个非常烦人的紫色下划线,我似乎无法摆脱它。我需要为此使用某种特殊属性吗?

最佳答案

对于文本颜色,试试这个 theme={{ colors: { text: '#fff' } }};对于下划线,请尝试 autoCorrect={false}

代码


<TextInput
   theme={{ colors: { text: '#fff' } }}
   autoCorrect={false}
  />

关于javascript - react native : Unable to change color of text within <TextInput> component,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62666909/

相关文章:

javascript - jQuery 添加新表行不在表末尾

reactjs - 使用 react-testing-library 时让 react-datepicker 正确显示

javascript - 在类组件react-native中声明const

javascript - MapView.Marker 在缩放和捏合时用户当前位置移动时不稳定

javascript - 如何使用 React Native JS 将一个页面重定向到另一个页面

javascript - 如何修改轴文本的sencha图表中的字体颜色和字体大小

javascript - 无法使用带有 div 元素的 "onclick"调用函数

javascript - asp.net javascript .click() 事件未在服务器上触发

javascript - 当用户从 React 的下拉列表中选择一个选项时如何启用另一个输入字段

javascript - 使用 React 进行组件间通信