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

Input 组件 onConfirm 事件无法清空 value #1502

Closed
bmcciscoding opened this issue Dec 13, 2018 · 4 comments
Closed

Input 组件 onConfirm 事件无法清空 value #1502

bmcciscoding opened this issue Dec 13, 2018 · 4 comments

Comments

@bmcciscoding
Copy link

问题描述
我在使用 Input 组件时,期望在 onConfirm 里清空 text。但是并没有。然后我查阅了相关问题,发现处理了
onInput 事件之后,就可以清空。然后我查阅文档并没有发现这样的说明。

复现步骤
[复现问题的步骤]

  1. 点击 Input
  2. 输入文字
  3. 点击确认
constructor(props) {
    super(props)
    this.state = {
       newTodoTitle: ''
    }
  }

// 这里可以贴代码
changeNewTodoTitle(e) {
    this.setState({
      newTodoTitle: e.target.value
    })
  }

  createTodo(data) {
    console.log('user done', data.target.value)
   this.setState({
      newTodoTitle: ''
    })

const newTodo = <Input 
      placeholder='创建一个新的 todo'
      value={this.state.newTodoTitle}
      onConfirm={this.createTodo.bind(this)}
      // 打开下面的注释 点击确认就会清空
      //onInput={this.changeNewTodoTitle}
      type='text'
      ></Input>

期望行为
期望不处理 onInput 也可以在 onComfirm 里清空 text

报错信息
没打开注释的效果
image

打开了注释的效果
image

打开了注释的效果

系统信息

  • 操作系统: [mac Moyave 10.14.1]
  • Taro 版本 [v1.2.0-beta.14]
  • Node.js 版本 [v11.2.0]
  • 报错平台 [weapp]

补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]

@taro-bot
Copy link

taro-bot bot commented Dec 13, 2018

欢迎提交 Issue~

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

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

Good luck and happy coding~

@luckyadam
Copy link
Member

小程序原生可以不处理 onInput 也可以在 onComfirm 里清空 text 么

@weimode
Copy link

weimode commented Apr 15, 2019

Input 组件怎么才能触发清空value?

@Winwuwentao
Copy link

官方好像还没有解决这个问题吧?

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