import {CHANNEL_GETCHANNEL,SET_ACTIVE} from '../action/acttionTypes'
// 定义频道的state
const inintChannels={
channel:[],
activeId:0
}
// 定义action
export const channel=(state = inintChannels, action)=> {
// console.log('reducer:', state, action)
switch (action.type) {
case SET_ACTIVE:
return {...state,activeId:action.payload}
// 处理频道列表
case CHANNEL_GETCHANNEL:
return {...state,channel:action.payload}
default:
return state
}
}
reducer模块化拆分中定义state和action的写法
最新推荐文章于 2023-09-10 23:24:27 发布