木四
木四
  • 发布:2019-10-22 11:06
  • 更新:2019-10-22 11:22
  • 阅读:1254

typescript编译失败,提示Accessors are only available when targeting ECMAScript 5 and higher.

分类:HBuilderX

下面这段代码编译报错:


let passcode = "secret passcode";  

class Employee {  
    private _fullName: string;  

    get fullName(): string {  
        return this._fullName;  
    }  

    set fullName(newName: string) {  
        if (passcode && passcode == "secret passcode") {  
            this._fullName = newName;  
        }  
        else {  
            console.log("Error: Unauthorized update of employee!");  
        }  
    }  
}  

let employee = new Employee();  
employee.fullName = "Bob Smith";  
if (employee.fullName) {  
    alert(employee.fullName);  
}  
2019-10-22 11:06 负责人:无 分享
已邀请:
8***@qq.com

8***@qq.com

里集体么的

8***@qq.com

8***@qq.com

佳佳11感觉哭咯

该问题目前已经被锁定, 无法添加新回复