ES6+REACT+MIXIN
来源:互联网 发布:淘宝好吃的点心店铺 编辑:程序博客网 时间:2024/05/21 22:38
ES6+REACT+MIXIN
文件结构
Action.jsHome.jsxindex.jsstore.js
Home.jsx
import React from 'react'import Reflux from 'reflux'import ReactMixin from 'react-mixin'import store from './store'import Actions from './Actions'class App extends React.Component { constructor(props) { super(props); Actions.getAll(); } render() { var t = this; var data = t.state.m; return <div onClick={Actions.add.bind(this)}> Hello World!!!<br /> {data.num} </div>; }}export default App;ReactMixin.onClass(App, Reflux.connect(store,'m'));
store.js
import Actions from './Actions'import Reflux from 'reflux'export default Reflux.createStore({ listenables: [Actions], onGetAll() { this.trigger(this.data); }, onAdd(item) { this.data.num += 1; this.trigger(this.data); }, onRemove(i) { this.data.num = 0; this.trigger(this.data); }, getInitialState() { var t = this; this.data = { num:0 }; return this.data; }});
index.js
module.exports = require('./Home.jsx');
Action.js
import Reflux from 'reflux';export default Reflux.createActions(['getAll','add','remove']);
如果更好的方法欢迎指导
0 0
- ES6+REACT+MIXIN
- React(7.2)--React ES6 处理 mixin
- React Mixin 的介绍
- React之Mixin
- React(7.1)--mixin
- react 学习--使用Mixin
- React Mixin HelloWorld
- React双向绑定Mixin
- 16、react之 MIxin
- React中的Mixin
- React中Mixin的使用
- React+ES6
- React Mixin 双向绑定 及 源码分析
- mixin
- mixin
- mixin
- MiXin
- ES6 for React
- 100天土鸡饲养计划(26)
- 数据库
- flex 遍历文件夹的问题显示图片问题
- jquery全选反选
- ble 蓝牙API
- ES6+REACT+MIXIN
- 不再这里更新啦,换新博客了
- session
- 批处理操作系统
- POJ3258【二分】
- html+css3
- Linux Netlink 基本使用
- BZOJ 2669([cqoi2012]局部极小值-状态压缩+dp)
- css3动画