简体   繁体   English

赋值表达式的左侧必须是变量或属性访问

[英]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.

相关问题 角度错误:赋值表达式的左侧必须是变量或属性访问 - Angular error: The left-hand side of an assignment expression must be a variable or a property access 赋值表达式的左侧必须是angular2中的变量或属性访问 - The left-hand side of an assignment expression must be a variable or a property access in angular2 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." 赋值表达式的左侧在Angular2中不能为常量或只读属性 - Left-hand side of assignment expression cannot be a constant or a read-only property in Angular2 赋值表达式的左侧不能是常量或只读属性 - Left-hand side of assignment expression cannot be a constant or a read-only property Jade Angular2作业左侧无效 - Jade Angular2 Invalid left-hand side in assignment 错误:ReferenceError:分配中的左侧无效 - Error: ReferenceError: Invalid left-hand side in assignment ReferenceError:导入@ google-cloud / storage时分配的左侧无效 - ReferenceError: Invalid left-hand side in assignment when importing @google-cloud/storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM