UNPKG

popbean-react

Version:

let me think about something,comming soon...

97 lines (96 loc) 1.99 kB
'use strict'; var React = require('react'); // // var Neptune = require('popbean.neptune'); // var {AppNav} = Neptune; var AppNav = require('../../../src/bs3/app-nav/app-nav'); //var AppNav = require('../../../component/common/bs3/app-nav'); var sb_style = require('../../../less/bs3/sb-spa-2.less'); // var Message = React.createClass({//用于展现自定义的内容 getDefaultProps:function(){ return { data:[] }; }, render:function(){ return ( <a href="#"> <div> <strong>{this.props.data.author}</strong> <span className="pull-right text-muted"> <em>{this.props.data.logdate}</em> </span> </div> <div>{this.props.data.msg}</div> </a> ); } }); // var actions = [ { icon:"fa fa-user fa-fw", label:"soso", children:[ { icon:"fa fa-user fa-fw", label:"用户档案" }, { icon:"fa fa-gear fa-fw", label:"设置" }, ] }, { icon:"fa fa-bell fa-fw" }, { icon:"fa fa-envelope fa-fw", renderComponent:Message, children:[ { author:"to0ld", logdate:"yesterdaty", "msg":"日日是好日" }, { author:"tealc", logdate:"tommoro", "msg":"日日是好日!" } ] }, ]; // var CmsIndex = React.createClass({ getInitialState:function(){ return { nodes:[] }; }, componentDidMount:function(){ var self = this; fetch('/service/cms/nodes') .then(function(response){ return response.json() }).then(function(json){ var data = json['data']; if(self.isMounted()){ self.setState({ nodes:data }); } }).catch(function(ex){ console.log('==>'+ex); }); }, render:function(){ //FIXME 需要把这一段改写成ajax调用 return( <AppNav title={'逐梦人'} version={'v1.0'} actions={actions} nodes={this.state.nodes}/> ); } }); module.exports = CmsIndex;