我现在正在expo上创建一个登录表单,我在./screen/HomeOneScreen.tsx中有这个
import * as React from 'react';
import { Image, StyleSheet, TouchableOpacity, TextInput } from 'react-native';
import EditScreenInfo from '../components/EditScreenInfo';
import { Text, View } from '../components/Themed';
export default function HomeOneScreen() {
const [email, onChangeText] = React.useState('Email');
const [password, onChangeText]= React.useState('Password');
return (
<View style={styles.container}>
<TextInput
style={{width: 200, height:40, borderColor: 'gray', borderWidth: 1}}
onChangeText={text=> onChangeText(text)}
email={email}
/><Text>{email}</Text>
<TextInput
style={{width: 200, height:40, borderColor: 'gray', borderWidth: 1}}
onChangeText={text=> onChangeText(text)}
password={password}
/>
<Text>{password}</Text>
<View style={styles.separator} lightColor="#eee" darkColor="rgba(255,255,255,0.1)" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
title: {
fontSize: 20,
fontWeight: 'bold',
},
separator: {
marginVertical: 30,
height: 1,
width: '80%',
},
logo: {
width: 50,
height: 50,
marginBottom: 10,
},
instructions: {
color: '#888',
fontSize: 18,
marginHorizontal: 15,
},
button: {
backgroundColor: "cyan",
padding: 20,
borderRadius: 5,
},
buttongreen: {
backgroundColor: "lime",
padding: 20,
borderRadius: 5,
},
buttonyellow: {
backgroundColor: "yellow",
padding: 20,
borderRadius: 5,
},
buttonText: {
fontSize: 20,
color: '#000',
},
});但是看起来它不喜欢我的双标识符: onChangeText 'onChangeText‘已经声明了。
当我在密码字段中将onChangeText替换为onChangeText2时,应用程序正在加载,但在打印变量password中无法识别密码。
我可以将密码字段放在哪里以及如何放置?
发布于 2021-02-16 20:18:26
我发现它在这里用onChangeText2 exept替换了onChangeText:
<TextInput
style={{width: 200, height:40, borderColor: 'gray', borderWidth: 1}}
onChangeText={text=> onChangeText2(text)}
password={password}
/>https://stackoverflow.com/questions/66224134
复制相似问题