简体   繁体   English

Coffeescript无效语法

[英]Coffeescript invalid syntax

Thoughts on why the following is invalid syntactically? 关于以下语法为何无效的思考?

@foo(@bar('/test', {
      password
      username
      _method: 'GET'
    }
  )
)

The problem is the indentation. 问题是压痕。

The second parenthesis couldn't be read properly. 无法正确读取第二个括号。 If you make an indent explicitly for it, it work. 如果您明确为其进行缩进,则该缩进将起作用。

@foo(
  @bar('/test', {
      password
      username
      _method: 'GET'
    }
  )
)

Or remove indentation of the closing parenthesis. 或删除右括号的缩进。

@foo(@bar('/test', {
    password
    username
    _method: 'GET'
  }
))

both of them works as 他们两个都作为

this.foo(this.bar('/test', {
  password: password,
  username: username,
  _method: 'GET'
}));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM