js: add generated child remove api

This commit is contained in:
王劲鹏
2020-05-15 17:58:25 +08:00
committed by osborn
parent 750215917b
commit 4d80048d60
7 changed files with 37 additions and 1 deletions

View File

@@ -123,4 +123,6 @@ export declare abstract class Group extends Superview {
readonly children: View[];
allSubviews(): View[];
addChild(view: View): void;
removeChild(view: View): void;
removeAllChildren(): void;
}

View File

@@ -329,4 +329,12 @@ export class Group extends Superview {
addChild(view) {
this.children.push(view);
}
removeChild(view) {
const ret = this.children.filter(e => e !== view);
this.children.length = 0;
ret.forEach(e => this.addChild(e));
}
removeAllChildren() {
this.children.length = 0;
}
}