class LifecycleLog { order: Object mounted: Object unmounted: Object parentMounted: Number childMounted: Number parentUnmounted: Number childUnmounted: Number latest: Object } class WatchedText: TextBlock { log: LifecycleLog function onMount(self: WatchedText, mount: Mount): Unit { self.log.order.increment() self.log.mounted.increment() self.log.childMounted = self.log.order.value self.log.latest.set(mount) self.setText("同一个对象,两个独立挂载位置") } function onUnmount(self: WatchedText, mount: Mount): Unit { self.log.order.increment() self.log.unmounted.increment() self.log.childUnmounted = self.log.order.value self.log.latest.set(mount) } } class WatchedColumn: Column { log: LifecycleLog function onMount(self: WatchedColumn, mount: Mount): Unit { self.log.order.increment() self.log.parentMounted = self.log.order.value } function onUnmount(self: WatchedColumn, mount: Mount): Unit { self.log.order.increment() self.log.parentUnmounted = self.log.order.value } } log = LifecycleLog(ui.state(0), ui.state(0), ui.state(0), 0, 0, 0, 0, ui.state(0)) child = WatchedText("等待挂载", 2, log) root = WatchedColumn(24, 16, child, child, TextBlock("挂载次数"), ui.textOf(log.mounted, "value"), TextBlock("卸载次数"), ui.textOf(log.unmounted, "value"), log) page = Page() page.render(root)