[英]The left-hand side of an assignment expression must be a variable or a property access
I am trying to create new const like this but i got error我正在尝试像这样创建新的常量,但出现错误
export const fakeExpertOperationalEdited: ExpertOperational = {
comment: 'comment',
useSlots: true,
workingDay: new ExpertWorkingDay[] = [
{
weekDay: 'MONDAY',
operationalAM: {
fixed: false,
startTime: '11:00',
endTime: '12:00'
},
operationalPM: {
fixed: false,
startTime: '11:00',
endTime: '12:00'
}
}
],
workSpeedSurvey: '10'
};
export class ExpertWorkingDay {
constructor(
public weekDay: WeekDays,
public operationalAM: ExpertWorkingHours,
public operationalPM: ExpertWorkingHours
) { }
}
This is my error这是我的错误
The left-hand side of an assignment expression must be a variable or a property access赋值表达式的左侧必须是变量或属性访问
Any one got idea where i am going wrong?有人知道我哪里出错了吗?
The problem is问题是
workingDay: new ExpertWorkingDay[] = [ ... ]
just try你试一试
workingDay: [ ... ]
because you can not create an array with new.因为你不能用 new 创建一个数组。 New is for instantiating classes.
New 用于实例化类。
So it would be所以它会
workingDay: [
new ExportWorkingDay( ... ),
new ExportWorkingDay( ... )
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.