<template>
<button @click="increment">
Count is: {{ state.count }}, double is: {{ state.double }}
</button>
</template>
<script lang="ts">
import { reactive, computed } from 'vue'
interface Count {
count: number;
double: object;
}
export default {
setup() {
const state: any = reactive<Count>({
count: 0,
double: computed(() => state.count * 2),
})
function increment() {
state.count++
}
return {
state,
increment,
}
},
}
</script>
vue3.0&typescripty --setup
最新推荐文章于 2024-06-04 16:42:26 发布