首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >关于React本地应用程序中的this.state函数

关于React本地应用程序中的this.state函数
EN

Stack Overflow用户
提问于 2019-11-22 10:02:33
回答 5查看 735关注 0票数 0

你好,这是我的代码。当我试图填充文本框时,错误出现了,即('this.setState不是一个函数。(在this.setState({emal:email)} this.setState被低估“)。

这里是我的代码:

导入反应从‘反应’;导入{图像,平台,ScrollView,StyleSheet,文本,TouchableOpacity,视图,TextInput,TouchableHighlight,警报

}从“反应-本地”开始;

导出默认函数LoginScreen() {

代码语言:javascript
运行
复制
  onClickListener = (viewId) => {
    Alert.alert("Alert", "You can't "+viewId);
  }

返回( https://png.icons8.com/message/ultraviolet/50/3498db'}}/> this.setState({email})}/>

代码语言:javascript
运行
复制
  <View style={styles.inputContainer}>
    <Image style={styles.inputIcon} source={{uri: 'https://png.icons8.com/key-2/ultraviolet/50/3498db'}}/>
    <TextInput style={styles.inputs}
        placeholder="Password"
        secureTextEntry={true}
        underlineColorAndroid='transparent'
        onChangeText={(password) => this.setState({password})}/>
  </View>

  <TouchableHighlight style={[styles.buttonContainer, styles.loginButton]} onPress={() => this.onClickListener('login')}>
    <Text style={styles.loginText}>Login</Text>
  </TouchableHighlight>

  <TouchableHighlight style={styles.buttonContainer} onPress={() => this.onClickListener('restore_password')}>
      <Text>Forgot your password?</Text>
  </TouchableHighlight>

  <TouchableHighlight style={styles.buttonContainer} onPress={() => this.onClickListener('register')}>
      <Text>Register</Text>
  </TouchableHighlight>
</View>

);}

代码语言:javascript
运行
复制
const styles = StyleSheet.create({
container: {
  flex: 1,
  justifyContent: 'center',
  alignItems: 'center',
  backgroundColor: '#DCDCDC',
},
inputContainer: {
    borderBottomColor: '#F5FCFF',
    backgroundColor: '#FFFFFF',
    borderRadius:30,
    borderBottomWidth: 1,
    width:250,
    height:45,
    marginBottom:20,
    flexDirection: 'row',
    alignItems:'center'
},
inputs:{
    height:45,
    marginLeft:16,
    borderBottomColor: '#FFFFFF',
    flex:1,
},
inputIcon:{
  width:30,
  height:30,
  marginLeft:15,
  justifyContent: 'center'
},
buttonContainer: {
  height:45,
  flexDirection: 'row',
  justifyContent: 'center',
  alignItems: 'center',
  marginBottom:20,
  width:250,
  borderRadius:30,
},
loginButton: {
  backgroundColor: "#00b5ec",
},
loginText: {
  color: 'white',
}
});
EN

Stack Overflow用户

回答已采纳

发布于 2019-11-22 10:06:25

这就是问题所在

代码语言:javascript
运行
复制
export default function LoginScreen()

将其更改为

代码语言:javascript
运行
复制
export default class LoginScreen extends Component
票数 0
EN
查看全部 5 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58991817

复制
相关文章

相似问题

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