React native 反应-处理<;Text/>;使用;SecureTextEntry“;喜欢<;TextInput/>;
我试图在react native docs中找到如何使用React native 反应-处理<;Text/>;使用;SecureTextEntry“;喜欢<;TextInput/>;,react-native,text,React Native,Text,我试图在react native docs中找到如何使用隐藏密码文本的道具 我有一个动态JS对象要显示,并使用map来处理: renderProfile(){ var tampil = this.state.data[0].detail.map((item, index)=>{ return( <View key={index}> <Text>{item.Header} :</Text> {
隐藏密码
文本的道具
我有一个动态JS对象要显示,并使用map
来处理:
renderProfile(){
var tampil = this.state.data[0].detail.map((item, index)=>{
return(
<View key={index}>
<Text>{item.Header} :</Text>
{
this.state.editProfile ?
item.Header == 'Password' || item.Header == 'Username' || item.Header == 'Telepon' ?
<View>
<TextInput
//MyProps
/>
{item.Header=='Password' && this.state.editProfile ? <FontAwesome onPress={()=>{this.setState({hidePassword: !this.state.hidePassword})}} name="eye" size={20} color="#000"/> : null}
</View>
: <Text>{item.Value}</Text>
: <Text>{item.Value}</Text>
}
</View>
)
})
return tampil
}
renderProfile(){
var tampil=this.state.data[0]。detail.map((项目,索引)=>{
返回(
{item.Header}:
{
这个.state.editProfile?
item.Header=='Password'| | item.Header=='Username'| | item.Header=='Telepon'?
{item.Header=='Password'&&this.state.editProfile?{this.setState({hidePassword:!this.state.hidePassword}}}}name=“eye”size={20}color=“#000”/>:null}
:{item.Value}
:{item.Value}
}
)
})
返回坦普尔
}
我可以用SecureTextEntry
处理
,但在
上我看不到SecureTextEntry道具
有没有办法在
组件中隐藏密码?您应该在密码字段中使用文本输入
<View>
<TextInput secureTextEntry={true}>
</TextInput>
</View>
由于中没有隐藏密码的道具,并且您希望使用
文本
节点,因此您可以制作自己的文本掩码
securePasswordEntry(值){
返回值&&value.replace(//g,'*'))
}
{securePasswordEntry(/*要保护的文本*/)}
你为什么不直接使用a并设置editable={false}
?我已经尝试过了,但是当editable=true
并且我编辑了文本时,我遇到了一个错误,你面对的是哪个错误?我已经知道
是否有securetextcentry
,我想在
上实现它,如果您想使用它,您应该使用onChangeText属性,然后将passwordText替换为类似点的passwordText.replace(“*”,“)
securePasswordEntry (value) {
return value && value.replace(/./g, '*')
}
<Text>{securePasswordEntry(/*Text you want to secure*/)}<Text>