首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >登录表单博览会

登录表单博览会
EN

Stack Overflow用户
提问于 2021-02-16 20:15:02
回答 1查看 48关注 0票数 0

我现在正在expo上创建一个登录表单,我在./screen/HomeOneScreen.tsx中有这个

代码语言:javascript
复制
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中无法识别密码。

我可以将密码字段放在哪里以及如何放置?

EN

回答 1

Stack Overflow用户

发布于 2021-02-16 20:18:26

我发现它在这里用onChangeText2 exept替换了onChangeText:

代码语言:javascript
复制
    <TextInput
        style={{width: 200, height:40, borderColor: 'gray', borderWidth: 1}}
        onChangeText={text=> onChangeText2(text)}
        password={password}
    />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66224134

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档