在react 0.13.2中使用react的数据双向绑定

来源:互联网 发布:手机淘宝中启用旺信 编辑:程序博客网 时间:2024/05/21 15:50
'use strict';import React from 'react/addons';import reactMixin from 'react-mixin';let { LinkedStateMixin } = React.addons;class App extends React.Component {  constructor() {    super();    this.state = {      name: ''    }  }  render() {    <input type='text'  valueLink={this.linkState('name')} />  }}reactMixin.onClass(App, LinkedStateMixin);

因为我的表单很多很复杂,用了之后直接减少了100多行代码。

建议大家在操作大量的表单时考虑使用。

0 0
原创粉丝点击