新增mvvm示例
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { ViewModel, observable, computed, command } from '@esengine/mvvm-ui-framework';
|
||||
|
||||
/**
|
||||
* 用户配置文件视图模型
|
||||
*/
|
||||
export class UserProfileViewModel extends ViewModel {
|
||||
|
||||
public get name(): string {
|
||||
return 'UserProfileViewModel';
|
||||
}
|
||||
|
||||
@observable
|
||||
avatar: string = '';
|
||||
|
||||
@observable
|
||||
nickname: string = '';
|
||||
|
||||
@observable
|
||||
email: string = '';
|
||||
|
||||
@observable
|
||||
phone: string = '';
|
||||
|
||||
@computed(['nickname', 'email'])
|
||||
get displayInfo(): string {
|
||||
return `${this.nickname} (${this.email})`;
|
||||
}
|
||||
|
||||
@command()
|
||||
public updateProfile(): void {
|
||||
console.log('更新用户配置文件');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "05648650-5963-4847-8789-7bdc6ea7f43c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user