猿问

xxx => xx = xxx 这是什么写法 es6

node => input = node
es6箭头函数倒是经常用,搞不清为啥最后还来个赋值

render() {

    let input = '';

    return (

      <div>

        <input ref={node => input = node} />

        <button type="submit" onClick={() => {

          console.log(input.value);

        }}>添加</button>

      </div>

    );

  }


慕尼黑5688855
浏览 928回答 3
3回答

梦里花落0921

就是箭头函数啊,只不过函数的主体就是一条 赋值语句,省略了函数大括号而已。

萧十郎

赋值就是赋值啊,没有特殊。let&nbsp;input&nbsp;=&nbsp;''; ...node&nbsp;=>&nbsp;input&nbsp;=&nbsp;node等价于let&nbsp;input&nbsp;=&nbsp;''; ... function&nbsp;fn(node)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;input&nbsp;=&nbsp;node; &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;input; }

白衣染霜花

简洁写法,相当于&nbsp;xxx => {let xx = xxx; return xx;}
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答