import { combineReducers } from 'redux';
import { ADD_TODO, COMPLETE_TODO, SET_VISIBILITY_FILTER, VisibilityFilters } from '../action/action';
const { SHOW_ALL } = VisibilityFilters;
最后面这句的意思是:重新定义一个变量接收 VisibilityFilters,就是相当于重命名吗?
这个是react+redux案例中的,SHOW_ALL是antion中VisibilityFilters中定义的:
exports const VisibilityFilters = {
SHOW_ALL: 'SHOW_ALL',
SHOW_COMPLETED: 'SHOW_COMPLETED',
SHOW_ACTIVE: 'SHOW_ACTIVE'
}
我没明白的是这个写法到底是表达的是什么意思,VisibilityFilters在上面一句已经导入了,然后为什么有用一个大括号的形式呢
ES6解构赋值。
const { SHOW_ALL } = VisibilityFilters;
相当于 const SHOW_ALL = VisibilityFilters.SHOW_ALL
解构赋值指南