javascript - ES6中Class的用法疑问◔ ‸◔?
PHPz
PHPz 2017-04-11 11:28:54
0
4
563
let methodName = 'getArea';
class Square{
  constructor(length){
    //..
  }
  [methodName](){
    //..
  }
}

在《ES6标准入门》中,18章讲到:

类的属性名可以采用表达式。

看不明白[]在这里的用途?

我知道的[]的用途:

  • 声明数组

  • 取数组成员

  • 定义对象成员

  • 取对象成员

这四个用途都跟上面代码中的[]用法不沾边呀(o´・ェ・`o)

PHPz
PHPz

学习是最好的投资!

répondre à tous(4)
洪涛

给你个链接 记得别采纳我。前几天有一样的问题。

黄舟

在 vuex中涉及的es6语法的小疑惑 中 @Dont 和我都已经回答过了。 @toBeTheLight 也搬过来了,我就是来回个邀请 ◔‸◔

Ty80

表示这是一个变量啊。

小葫芦

其中的用途可以是这样..等等

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!