小编use*_*066的帖子

使用onBlur与JSX和React

我正在尝试创建一个密码确认功能,只有在用户离开确认字段后才会出现错误.我正在使用Facebook的React JS.这是我的输入组件:

<input
    type="password"
    placeholder="Password (confirm)"
    valueLink={this.linkState('password2')}
    onBlur={this.renderPasswordConfirmError()}
 />
Run Code Online (Sandbox Code Playgroud)

这是renderPasswordConfirmError:

renderPasswordConfirmError: function() {
  if (this.state.password !== this.state.password2) {
    return (
      <div>
        <label className="error">Please enter the same password again.</label>
      </div>
    );
  }  
  return null;
},
Run Code Online (Sandbox Code Playgroud)

当我运行页面时,输入冲突的密码时不会显示该消息.

html onblur reactive-programming reactjs react-jsx

28
推荐指数
1
解决办法
9万
查看次数

标签 统计

html ×1

onblur ×1

react-jsx ×1

reactive-programming ×1

reactjs ×1