【问题标题】:TSLint returns expected an assignment or function call when assigning variablesTSLint 在分配变量时返回预期的赋值或函数调用
【发布时间】:2016-09-12 03:29:55
【问题描述】:

我正在使用 tslint 检查我的 angular 2 项目,但遇到了一些我不太了解的错误。以下代码片段收到“预期的赋值或函数调用”错误,但这不正是我的代码正在做的吗?

getUsers() {
    this._userService.getUsers().subscribe(data => {
        this.userList = data.users,
        this.number_of_pages = data.number_of_pages,
        this.number_of_users = data.number_of_users;
    });
}

这是一个错误还是我没有正确理解错误?我正在使用打字稿版本 1.8.10。

编辑:错误发生在第一次分配,所以this.userList = data.users

【问题讨论】:

  • 发生错误的确切行是哪一行?谢谢!
  • 第一次作业时。

标签: typescript angular tslint


【解决方案1】:

我认为问题在于你没有在两行末尾使用分号而是逗号:

this.userList = data.users, // <----
this.number_of_pages = data.number_of_pages, // <----
this.number_of_users = data.number_of_users;

您应该使用以下内容:

this.userList = data.users; // <----
this.number_of_pages = data.number_of_pages; // <----
this.number_of_users = data.number_of_users;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多