javascript三点语法

时间:2017-11-16 02:44:40

标签: javascript vuejs2 vue-component vuetify.js

我在Vuetify中使用this file作为vue应用,我看到了一种非常奇怪的语法,我无法找到它是什么

第38行

const data = {
    attrs: { disabled: this.disabled },
    class: this.classes,
    props: {},
    directives: [{
      name: 'ripple',
      value: this.ripple || false
    }],
    on: {
      ...(this.$listeners || {}),  // <<<---- here
      click: this.click
    }
  }
谁能告诉那三个点是什么?关于这个的任何文章都会很好

感谢

2 个答案:

答案 0 :(得分:2)

那是spread operator!它从对象中获取所有属性。

在该示例中,它将复制对象而不进行变异。

答案 1 :(得分:1)

它是一个扩展运算符,在ES6中用于Javascript中的对象和数组。这里,提取(this。$ listeners || {})的返回值。此返回值与click:this.click一起添加到另一个空对象中,跟在“on:”

之后