Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript中三点运算符的含义是什么_Javascript_Reactjs - Fatal编程技术网

Javascript中三点运算符的含义是什么

Javascript中三点运算符的含义是什么,javascript,reactjs,Javascript,Reactjs,我看到了rubix代码 (站点右上演示单击) 它是react组件中的代码 javascript //react ES6 var InboxItem = React.createClass({ mixins: [State, Navigation], statics: { ID: 0, resetID: function() { InboxItem.ID = 0; }, getID: function() { return ++Inb

我看到了rubix代码

(站点右上演示单击)

它是react组件中的代码

javascript

//react ES6
var InboxItem = React.createClass({
  mixins: [State, Navigation],
  statics: {
    ID: 0,
    resetID: function() {
      InboxItem.ID = 0;
    },
    getID: function() {
      return ++InboxItem.ID;
    }
  },
  handleClick: function(e) {
    e.preventDefault();
    e.stopPropagation();
    this.transitionTo('/app/mailbox/mail');
  },
  render: function() {
    var classes = classNames({
      'inbox-item': true,
      'unread': this.props.unread
    });

    var props = {
      href: '/app/mailbox/mail',
      onClick: this.handleClick,
      ...this.props,
      className: classes
    };

    return (
      <a {...props}>
        <div className='inbox-avatar'>
          <img src={this.props.src} width='40' height='40' className={this.props.imgClass + ' hidden-xs'} />
          <div className='inbox-avatar-name'>
            <div className='fg-darkgrayishblue75'>{this.props.name}</div>
            <div><small><Badge className={this.props.labelClass} style={{marginRight: 5, display: this.props.labelValue ? 'inline':'none'}}>{this.props.labelValue}</Badge><span>{this.props.description}</span></small></div>
          </div>
          <div className='inbox-date hidden-sm hidden-xs fg-darkgray40 text-right'>
            <div style={{position: 'relative', top: 5}}>{this.props.date}</div>
            <div style={{position: 'relative', top: -5}}><small>#{InboxItem.getID()}</small></div>
          </div>
        </div>
      </a>
    );
  }
});
//反应ES6
var InboxItem=React.createClass({
混合:[状态,导航],
静力学:{
ID:0,
resetID:函数(){
InboxItem.ID=0;
},
getID:function(){
return++InboxItem.ID;
}
},
handleClick:函数(e){
e、 预防默认值();
e、 停止传播();
这个.transitiono('/app/mailbox/mail');
},
render:function(){
var classes=类名({
“收件箱项目”:true,
“未读”:this.props.unread
});
变量props={
href:'/app/mailbox/mail',
onClick:this.handleClick,
…这是道具,
类名:类
};
返回(
{this.props.name}
{this.props.labelValue}{this.props.description}
{this.props.date}
#{InboxItem.getID()}
);
}
});
单击下一行代码

…这是道具

返回下一行代码

a{……道具}


这是什么?“…”

如本书中提到的@zerkms;这是中的对象Rest/Spread属性语法,也在中提到

你看到的代码

var props = {
  href: '/app/mailbox/mail',
  onClick: this.handleClick,

  ...this.props,

  className: classes
};
计算如下,其中
props
对象属性扩展到新的props对象上:

var props = {
  href: '/app/mailbox/mail',
  onClick: this.handleClick,

  src: 'https://example.com',
  name: 'myName',
  labelClass: 'myLabelClass',
  labelValue: 'mylabelValue',

  className: classes
};

这是一个非标准化的ES2016对象扩展操作符@虫族认为你们,先生,我发现那个篇文章看起来很相似,但并不相关