我必须为textInput的占位符文本更改字体系列.如果我们添加这个secureTextEntry={true},所提到的字体系列将被设置为占位符文本.

<TextInput style={styles.textboxfield}  secureTextEntry={true} placeholder="Password" />

但如果我们删除这个secureTextEntry={true},我们就不能为占位符设置字体系列

<TextInput style={styles.textboxfield} placeholder="Password" />

样式为:textboxfieldd:{

如何更改占位符文本的字体系列?

推荐答案

试试这个:

<TextInput
    secureTextEntry={(this.state.email.length <= 0 && this.state.emailStatus != 'onFocus') ? true : false}
    style={styles.textboxfieldd}
    placeholderStyle={styles.textboxfieldd}
    onFocus={this.changeStatus.bind(this, 'emailStatus', 'onFocus', '')}
    onChangeText={(email) => this.setState({ email })}
    value={this.state.email}
    placeholder={this.state.emailStatusPH}
    placeholderTextColor="#D8D8D8" />

Exactly this line => secureTextEntry={(this.state.email.length<=0 && this.state.emailStatus!='onFocus') ?true:false} solves the problem .

因为如果我们给secureTextEntry={true}意味着fontfamily被设置为占位符文本,但字段被更改为密码,所以只有我们这样写.{textEntry};&textOnState='this.secureFocus!<

如果该字段长度为0且未聚焦,则表示它将设置true secureTextEntry={true},因此占位符文本将设置为0

React-native相关问答推荐

错误:HostBody::get for prop NativeUnimoduleProxy中出现异常- Android虚拟设备(AVD)使用Expo测试React Native App时崩溃

在Reaction Native With EXPO中播放来自OpenAI TTS API的音频响应

在第二次加载时仅将本机应用程序设置为状态

无法读取 @react-native-async-storage/async-storage 的未定义属性setItem

应用管理

React onPress 立即执行(渲染时间),但是一旦用箭头函数替换它就不起作用

'未能找到 React 根视图的片段' React Native Android RNScreens

获取 TypeError:this.InnerNativeModule.configureProps 不是 mac 上 expo 中的函数

在 React Native 中从 Modal 打开 Modal

ReactJS toLowerCase 不是一个函数

React Native 错误:Animated.event now requires a second argument for options

fetch API 总是返回 {"_U": 0, "_V": 0, "_W": null, "_X": null}

Test suite无法运行 TypeError:Cannot read property ‘default’ of undefined

如何判断 goBack() 函数在react-navigation 中是否可行?

React-Native Android 中隐藏(hide)的元素溢出

试图注册两个同名的视图 RNGestureHandlerButton

如何从 stack.navigation 外部的组件中使用 navigation.navigate

opneUrl react-native 链接调用,mailto

react-native如何禁用android开发模式

如何从react-native应用程序打开外部应用程序?