LuoQaxa / blog

learning record blog
1 stars 0 forks source link

Day25 #19

Open LuoQaxa opened 7 years ago

LuoQaxa commented 7 years ago
  1. model
    
    import Immutable from 'immutable';

export class NewsComment { static create() { return Immutable.fromJS({ id: '', content: '', vote: [] }); } }

export class News { static create() { return Immutable.fromJS({ id: '', content: '', comments: [] }); } }

2、定义Action

import { createAction } from 'redux-actions'; import { ACT_NEWS_SELECT } from './constants';

export const actNewsSelect = createAction(ACT_NEWS_SELECT);

3、使用Action

onSelectNews(id){ //触发action console.log('onSelectNews') this.props.actNewsSelect(id) Actions['articledetail']() }

function bindAction(dispatch) { return { actNewsSelect: (id) => dispatch(actNewsSelect(id)) } }