Files
vue-tui/examples/basic-template/src/Clock.vue
T
Yunfei He 20b412ace1 refactor: convert all SFCs to script setup
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 22:39:11 +08:00

25 lines
519 B
Vue

<script setup lang="ts">
import { shallowRef, onMounted, onUnmounted } from "vue";
import { Box, Text } from "@vue-tui/runtime";
const time = shallowRef(new Date().toLocaleTimeString());
let timer: ReturnType<typeof setInterval>;
onMounted(() => {
timer = setInterval(() => {
time.value = new Date().toLocaleTimeString();
}, 1000);
});
onUnmounted(() => {
clearInterval(timer);
});
</script>
<template>
<Box>
<Text>Clock: </Text>
<Text bold color="yellow">{{ time }}</Text>
</Box>
</template>