Taro: Form 能获取到自定义表单组件的 name 但是没有值

Created on 9 Apr 2020  ·  8Comments  ·  Source: NervJS/taro

问题描述

// Textinput.jsx
static behaviors = ['wx://form-field']
static defaultProps = {
  title: '',
  name: '',
  value: ''
}

<View className='text-input'>
  <Text className='label'>{title}</Text>
  <Input name={name} value={value} />
</View>

// page.jsx
<Form onSubmit={this.handleSubmit}>
  <TextInput title='标题' name='test' />
</Form>

handleSubmit 里获取的 value{ test: '' },不管输了什么值,test 永远是空字符串

系统信息

Taro CLI 2.0.3 environment info:
System:
OS: macOS 10.14.6
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.12.0 - /usr/local/bin/node
npm: 6.11.2 - /usr/local/bin/npm

question

Most helpful comment

@afishhhhh @mihuartuanr 你们需要在输入时设置 value

image

All 8 comments

CC @Chen-jj

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

请问,目前这个找到解决方案了么

请问,目前这个找到解决方案了么

没有,用 state

😯我是循环的,改成static behaviors = ['wx://form-field-group']是可以的,你这里只是单个,不知道换成group可不可以

😯我是循环的,改成static behaviors = ['wx://form-field-group']是可以的,你这里只是单个,不知道换成group可不可以

我只是 demo 写了单个,我看了下 form-field-group 要基础库 2.10.2,还是得兼容

@afishhhhh @mihuartuanr 你们需要在输入时设置 value

image

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

Was this page helpful?
0 / 5 - 0 ratings