2

Operationclass 创建一个像这样的数组,它在数组之前没有类名。

[operInputQuery[0].value, operInputQuery[1].value, operInputQuery[2].value]

'Table' 类旨在成为继承Operation' 构造函数的未命名类。

它可以正确继承,但是,它会extends像这样使用不必要的标签创建数组。

extends[operInputQuery[0].value, operInputQuery[1].value, operInputQuery[2].value, operInputQuery[3].value]

是的,我不想用“扩展”的东西创建数组。

如何创建一个未命名的扩展类?

let Operation = class { //unamed class
  constructor(a, b, c) {
    this.a = operInputQuery[0].value;
    this.b = operInputQuery[1].value;
    this.c = operInputQuery[2].value;
  }
}

let Table = class extends Operation { //purposed to write an unnmaed extended class
  constructor(a, b, c, d){
    super(a, b, c);
    this.a;
    this.b;
    this.c;
    this.d = operInputQuery[3].value;
    }
};

4

1 回答 1

0

operInputQuery 丢失,但我猜是具有 value 属性的对象数组,试试这个:

let operInputQuery = [{value: 1}, {value: 2}, {value: 3}, {value: 4}];

let Table = class { 
  constructor(a, b, c, d){
    this.a = a;
    this.b = b;
    this.c = c;
    this.d = d;
    }
};

let table = new Table(operInputQuery[0].value, operInputQuery[1].value, operInputQuery[2].value, operInputQuery[3].value);
console.log(table);

于 2020-08-15T06:46:21.207 回答