ARKTS: 鸿蒙编程-定义类
如果ARKTS编程语言对 类中定义的对象 不赋初始值就必须写
constructor ,否则,不用写constructor .
例如:
export class fooClass{
id: number;
name: string;
constructor (id:number, name:string){
this.id = id,
this.name = name
}
}
不用写constructor 的例子:
export class fooClass{
id: number = 0;
name: string = '';
}
优质生活从拆开始
浙公网安备 33010602011771号