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

'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多行代码。

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章