以下表格是 Omi 的生命周期:
举个例子:
1234567891011121314151617181920
<template name="component-name"> <div>Seconds: {this.data.seconds}</div></template><script> export default class { data = { seconds: 0 } tick() { this.data.seconds++ this.update() } install() { this.interval = setInterval(() => this.tick(), 1000) } uninstall() { clearInterval(this.interval) } }</script>