Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

急:Form 表单如何提交如何获取其中input的各字段的值 #122

Closed
Yhaojing opened this issue Sep 5, 2016 · 7 comments
Closed

Comments

@Yhaojing
Copy link

Yhaojing commented Sep 5, 2016

<Form> <FormCell warn={isValidInput[0]} > <CellHeader> <Label>手机号</Label> </CellHeader> <CellBody> <Input type="tel" placeholder="输入手机号" /> </CellBody> <CellFooter > <Icon value="warn" /> </CellFooter> </FormCell> <FormCell> <Button onClick={this.handleSubmit}>登录绑定</Button> </FormCell> </Form>
这样提交表单在handleSubmit 中怎么获取输入的手机号?

@maigoxin
Copy link

maigoxin commented Sep 5, 2016

同问,我本来以为可以通过ref来解决。发现ref获取的是Input组件~ 希望有结果了能通知一下

@haibinyu
Copy link
Contributor

haibinyu commented Sep 5, 2016

通过onChange事件。

@Yhaojing
Copy link
Author

Yhaojing commented Sep 5, 2016

我不想通过ref取值,难道weui没有取值的方法吗?还有我是想在最后提交的时候获取表单值,不是在输入的时候获取

@n7best
Copy link
Collaborator

n7best commented Sep 5, 2016

用state存值 onchange更新
可以看react form的推荐使用方法
https://facebook.github.io/react/docs/forms.html

@maigoxin
Copy link

maigoxin commented Sep 5, 2016

onchange state的实现模式还是比较好理解。我这里有一个问题,这样的实现方式会不会导致dom被频繁的刷新呢? react不是每一次state修改就有可能触发dom diff吗?

@n7best
Copy link
Collaborator

n7best commented Sep 5, 2016

@maigoxin react刷新是很频繁的 如果怕影响整体可以单独组件上用shouldComponentUpdate来判断是否需要更新dom

@n7best n7best closed this as completed Oct 26, 2016
@kala888
Copy link

kala888 commented Jan 22, 2018

有没有比较统一的解决方案类似于rc-form,集成rc-form,失败

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants