js语句看不懂 求教
- 似水export const increment = (counterCaption) => {
AppDispatcher.dispatch({
type: ActionTypes.INCREMENT,
counterCaption: counterCaption
});
};
上述代码看不懂. 这里的increment是变量还是数值还是函数名还是对象还是函数啊?
到底输出什么? 请指教输出的是:
1. const increment 常量的值
还是
2. 这一个函数:
(counterCaption) => {
AppDispatcher.dispatch({
type: ActionTypes.INCREMENT,
counterCaption: counterCaption
});
还是
3.这一个函数
AppDispatcher.dispatch({
type: ActionTypes.INCREMENT,
counterCaption: counterCaption
});
还是
4. 这个Json:
{
type: ActionTypes.INCREMENT,
counterCaption: counterCaption
}
还是
5. increment对象? - by曲终人散看起来像个reducer。导出的是个函数。
- 木目心这是一个自增方法的定义
参数是 counterCaption
方法体里没有直接执行自增,而是转发了一条自增的指令 ActionTypes.INCREMENT
所有会响应这条指令的方法都会被执行
应该是用了vuex - 夜空楼上说的很明白了,看下vuex iOS fly ~
- napa0421输出的是个箭头函数 PM2.5
- 木目心输出的是一个函数定义
表示你在其它文件可以调用increment这个函数 - 似水回复5#napa0421
谢谢
输出箭头函数的话直接写 export (counterCaption) => {
AppDispatcher.dispatch({
type: ActionTypes.INCREMENT,
counterCaption: counterCaption
});
};
就行了, 为什么要加const increment =啊? - Rorysky尖头函数了解下 iOS fly ~
- z16166arrow functions
https://developer.mozilla.org/zh ... ons/Arrow_functions - napa0421回复7#似水
你去看看阮一峰的es6吧 PM2.5