import * as types from '../constants/ActionTypes';
export function addTodo(text) {
return { type: types.ADD_TODO, text }
}
export function deleteTodo(id) {
return { type: types.DELETE_TODO, id }
}
export function editTodo(id, text) {
return { type: types.EDIT_TODO, id, text }
}
export function completeTodo(id) {
return { type: types.COMPLETE_TODO, id }
}
export function completeAll() {
return { type: types.COMPLETE_ALL }
}
export function clearCompleted() {
return { type: types.CLEAR_COMPLETED }
}
这里面的 * 是什么用途,在后续的代码中没看到有用到*的地方。
高洛峰2017-04-10 18:08:11
constants/ActionTypes:
export const a = 1;
export const b = 2;
import * as types from '../constants/ActionTypes';
types 就是
{a:1,b:2}
针对你给出的代码就是
{
addTodo,
deleteTodo,
editTodo,
completeTodo,
completeAll,
clearCompleted
}
天蓬老师2017-04-10 18:08:11
ECMAScript6 import语法,参考模块整体加载
翻译一下好了:
import (引入) * (所有export属性) as (到) types (types变量) from (从) '../constants/ActionTypes' (ActionTypes)