【问题标题】:How to return nested object in NodeJS module.export?如何在 NodeJS module.export 中返回嵌套对象?
【发布时间】:2017-10-12 11:25:51
【问题描述】:

挂断了这个。

module.exports = {

  capital: {
     name: "Berlin",
     population: 10000,
     area: 15
  },
  country-code: "de",
  langauge: "german"
}

引发错误“意外令牌”。如果我消除嵌套一切正常。

【问题讨论】:

  • 怀疑... country-code: "de", 无效-我的意思是,错误指向该行,特别是- 字符...
  • 太搞笑了!你说的对。非常感谢。

标签: javascript node.js object


【解决方案1】:

对象名称中不允许使用连字符 (-)。解析器会将其解释为减法运算符。

感谢:@Jaromanda X

【讨论】:

    猜你喜欢
    • 2018-12-17
    • 1970-01-01
    • 1970-01-01
    • 2021-06-09
    • 2019-01-20
    • 2014-05-02
    • 1970-01-01
    • 2021-05-19
    • 2020-05-24
    相关资源
    最近更新 更多