您现在的位置:首页 >> 前端 >> 内容

Refluxhelloworld

时间:2016/12/19 9:21:06 点击:

  核心提示:如下代码是reflux 的骨架import React from react;import Reflux from refluxvar ReactDOM = require(react-dom);va...

如下代码是reflux 的骨架

import React from 'react';
import Reflux from 'reflux'
var ReactDOM = require('react-dom');
var mainAction = Reflux.createActions([
    'sayHello'
]);
var mainStore = Reflux.createStore({
    listenables: [mainAction],
    getInitialState:function(){
        return {name:"default"}
    },
    data: {},
    onSayHello: function (val) {
        this.data.name = "hello " + val;
        this.trigger(this.data);
    }
})
var HelloWorld = React.createClass({
    mixins: [Reflux.connect(mainStore, "xixi")],
    say: function () {
        mainAction.sayHello("lili");
    },
    render: function () {
        return <p>
            <a onClick={this.say}>点击触发</a>
            <p >{ this.state.xixi.name}</p>
        </p>
    }
})
ReactDOM.render(
    <HelloWorld />
    , document.getElementById('J_contentContainer'))

Tags:RE EF FL LU 
作者:网络 来源:ISaiSai的专栏
  • 上一篇:CSS单位
  • 下一篇:Node.jsPath模块