Twitter bootstrap 通过回调处理``完成
意图:我希望在提交/单击finish按钮后使用用户填写表单的数据,以便在函数/回调中读取/处理 尝试过的解决方案:我用login创建了一个finish/login/submit按钮,现在有一个问题,我不知道如何访问输入字段中的数据。我想我不得不用这些名字或身份证,但我想不出来 问题:如何从登录中的字段获取用户输入数据 代码:Twitter bootstrap 通过回调处理``完成,twitter-bootstrap,reactjs,reactstrap,Twitter Bootstrap,Reactjs,Reactstrap,意图:我希望在提交/单击finish按钮后使用用户填写表单的数据,以便在函数/回调中读取/处理 尝试过的解决方案:我用login创建了一个finish/login/submit按钮,现在有一个问题,我不知道如何访问输入字段中的数据。我想我不得不用这些名字或身份证,但我想不出来 问题:如何从登录中的字段获取用户输入数据 代码: import React from 'react'; import {Button, Form, FormGroup, Label, Input, Container} f
import React from 'react';
import {Button, Form, FormGroup, Label, Input, Container} from 'reactstrap';
class AWSLogin extends React.Component {
login() {
console.log(???); //< Should output the user input in the form field with id "aws_access_key_id"
};
render() {
return (
<Container>
<Form>
<FormGroup>
<Label for="aws_access_key_id">AWS Access Key ID</Label>
<Input type="string" name="aws_access_key_id" id="aws_access_key_id"
placeholder="AKIAIQBMB7KQWPNDFT7A"/>
</FormGroup>
<Button color="primary" onClick={this.login}>Login</Button>
</Form>
</Container>
);
}
}
export default AWSLogin;
你为什么不在提交后试试这个来获取表单呢
handleSubmit = (event) => {
console.log('form submitted');
}
<form onSubmit={this.handleSubmit}>
...
</form>
对于输入,您可以尝试,或者类似的方式
<Input name="input1" type="text" onChange={(e) => this.onChange(e.target.value)}/>
我还建议您在这里查看演示Thx,很抱歉,我没有找到其他问题。出于某种原因,顺便说一句,我不得不更改按钮的onClick属性,因为它在处理程序中丢失了,但是它工作了onClick={=>{this.login}}没有尝试,因为链接的重复答案有帮助,但是感谢您的努力!不用担心,很高兴问题解决了。