[英]TSLint returns expected an assignment or function call when assigning variables
I am using tslint to check my angular 2 project and am getting some errors that I don't really understand. 我正在使用tslint检查我的angular 2项目,但遇到了一些我不太了解的错误。 The following code snippit gets a "expected an assignment or function call"-error, but isn't that exactly what my code is doing?
以下代码段收到“预期的分配或函数调用”错误,但这不是我的代码正在做什么吗?
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;
});
}
Is this a bug or do I not understand the error correctly? 这是错误还是我无法正确理解错误? I am using typescript version 1.8.10.
我正在使用打字稿版本1.8.10。
Edit: The error occures at the first assignment, so this.userList = data.users
编辑:错误发生在第一次分配,因此
this.userList = data.users
I think the problem is that you don't use semi-colons but comma at the end of two lines: 我认为问题在于您没有使用分号,而是在两行的末尾使用逗号:
this.userList = data.users, // <----
this.number_of_pages = data.number_of_pages, // <----
this.number_of_users = data.number_of_users;
You should use the following: 您应该使用以下内容:
this.userList = data.users; // <----
this.number_of_pages = data.number_of_pages; // <----
this.number_of_users = data.number_of_users;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.