简体   繁体   English

赋值表达式的左侧在Angular2中不能为常量或只读属性

[英]Left-hand side of assignment expression cannot be a constant or a read-only property in Angular2

Here's how my code looks like 这是我的代码的样子

this.timezones = moment.tz.names();
for(let timezone in this.timezones) {
  this.timezones[timezone] = this.timezones[timezone] +' '+ moment.tz(this.timezones[timezone]).format('Z z');
}

I am getting the above mentioned error in line present inside for loop, I didn't get this error until i upgraded to angular2.1 我在for循环中的行中收到上述错误,直到升级到angular2.1,我才收到此错误

is there any other way to access the elements of timezones variable to make it writable as well? 还有其他方法可以访问timezones变量的元素以使其可写吗?

as per docs of moment timezone 根据时区的文档

moment.tz.names(); // String[]

gives string array. 给出字符串数组。

now, 现在,

this.timezones[timezone] is undefined. 

暂无
暂无

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

相关问题 赋值表达式的左侧不能是常量或只读属性 - Left-hand side of assignment expression cannot be a constant or a read-only property 赋值表达式的左侧必须是angular2中的变量或属性访问 - The left-hand side of an assignment expression must be a variable or a property access in angular2 Jade Angular2作业左侧无效 - Jade Angular2 Invalid left-hand side in assignment 赋值表达式的左侧必须是变量或属性访问 - The left-hand side of an assignment expression must be a variable or a property access 角度错误:赋值表达式的左侧必须是变量或属性访问 - Angular error: The left-hand side of an assignment expression must be a variable or a property access Angular 错误-“赋值表达式的左侧可能不是可选属性 access.ts”? - Angular error- "The left-hand side of an assignment expression may not be an optional property access.ts"? 我正在制作图像轮播,但出现错误:赋值表达式的左侧可能不是可选的属性访问 - i'm making a carousel of images and i've the error : The left-hand side of an assignment expression may not be an optional property access 尝试初始化嵌套数组时出错“赋值表达式的左侧可能不是可选的属性访问。” - Getting error when trying to initialize nested array "The left-hand side of an assignment expression may not be an optional property access." 角度2 | 无法分配给变量,因为它是常量或只读属性 - Angular 2 | cannot assign to variable because it is a constant or a read-only property 角度2 | 无法分配给数组,因为它是常量或只读属性 - Angular 2 | cannot assign to array because it is a constant or a read-only property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM