0
我想将item
变量dynamic添加到此属性中,例如如果该项目有35
价值将成为this.BookingConfirmationFormsState35
将动态变量添加到此属性
onChange(event, item){
console.log(this.BookingConfirmationFormsState+item); // Doesn't work
}
我想将item
变量dynamic添加到此属性中,例如如果该项目有35
价值将成为this.BookingConfirmationFormsState35
将动态变量添加到此属性
onChange(event, item){
console.log(this.BookingConfirmationFormsState+item); // Doesn't work
}
你需要使用括号符号[]
访问动态属性名称:
this['BookingConfirmationFormsState' + item];
对于item = 35
,上面的代码就相当于到:
this.BookingConfirmationFormsState35
onChange(event, item){
console.log(this['BookingConfirmationFormsState' + item]);
}