JavaScript“ this”如何与$ {}一起使用?

时间:2018-08-10 05:27:41

标签: javascript object this

我有以下代码:

module.export = { 
  OBJECT: { 
    "key01": "value01", 
    "key02": "value02" },
  ARRAY: {
    NESTED_ARRAY: [
      `my.object.${this.OBJECT.key01}`,
      `my.object.${this.OBJECT.key02}`,
      ]
  }
}

console.log(ARRAY.NESTED_ARRAY[0] === my.object.value01)

如何使上面的console.log语句正确?

1 个答案:

答案 0 :(得分:1)

将console.log(ARRAY.NESTED_ARRAY [0] === my.object.value01)更改为 console.log(ARRAY.NESTED_ARRAY [0]!== my.object.value01)