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对象?
  • b
    by曲终人散
    看起来像个reducer。导出的是个函数。
  • 木目心
    这是一个自增方法的定义
    参数是 counterCaption
    方法体里没有直接执行自增,而是转发了一条自增的指令 ActionTypes.INCREMENT
    所有会响应这条指令的方法都会被执行

    应该是用了vuex
  • 夜空
    楼上说的很明白了,看下vuex iOS fly ~
  • n
    napa0421
    输出的是个箭头函数 PM2.5
  • 木目心
    输出的是一个函数定义
    表示你在其它文件可以调用increment这个函数
  • 似水
    回复5#napa0421

    谢谢
    输出箭头函数的话直接写 export (counterCaption) => {
    AppDispatcher.dispatch({
    type: ActionTypes.INCREMENT,
    counterCaption: counterCaption
    });
    };
    就行了, 为什么要加const increment =啊?
  • R
    Rorysky
    尖头函数了解下 iOS fly ~
  • z
    z16166
  • n
    napa0421
    回复7#似水
    你去看看阮一峰的es6吧 PM2.5