标签:tree click import xxx pac hub 点击 length webpack
import { Route, IndexRoute, Router, hashHistory, browserHistory } from ‘react-router‘;
<Router routes={routes} history={browserHistory}/>
{
comment: {
comments:[],
leng:0
}
detail: {
content: "xxx"
}
home: {
loading: false,
pos: 0,
stories: []
}
}
//在home里面跳转是触发fetchDetailData
<Link to={ ‘/detail/‘+item.id} onClick={this.props.fetchDetailData.bind(this,item.id) }>
获取完详情数据后,这样store数据就成以下结构
{
comment: {
comments:[]
leng:0
}
detail: {
content:"xxx"
}
home: {
loading:false
pos:29228
stories:Array(201)
}
}
//在详情页detail里面跳转是触发fetchCommentData
<Link to={ ‘/comment/‘+this.articleId} onClick={this.props.fetchCommentData.bind(this, this.articleId) }>评论</Link>
获取完评论数据后,这样store数据就成以下结构
{
comment: {
comments:Array(20)
leng:20
}
detail: {
content:"xxx"
}
home: {
loading:false
pos:29228
stories:Array(201)
}
}
//在返回主页home时,在主页做判断,回到最初的最初点击跳转时的位置 componentDidMount () { if(this.props.stories.length === 0 ){ this.props.fetchHomeData(this.s) }else{ console.log(this.props.route.component.displayName) if(this.props.route.component.displayName == "Connect(Home)"){ window.scrollTo(0,this.props.pos); } this.s() } }
github地址:https://github.com/fengnovo/webpack-react/tree/master/simpleFetch
顺便介绍一个好东西,MacDown,麦当劳,一款专门给mac用写markdown的软件工具,开源免费又好用
地址:http://macdown.uranusjr.com/
react-router与react-redux跳转后保存store数据(基于"react-router": "^2.8.0")
标签:tree click import xxx pac hub 点击 length webpack
原文地址:http://www.cnblogs.com/fengnovo/p/6927871.html