<script setup>
import { ref, onMounted } from 'vue'
import './index.css'

const count = ref({
  num: 0,
})

const handleCount = () => {
  count.value.num++
  console.log(count)
}

onMounted(() => {
  console.log(1)
})
</script>

<template>
  <div class="m-home-wrap">
    <button @click="handleCount">{{ count.num }}</button>
    <div class="m-home-demo"></div>
  </div>
</template>

<style></style>

vue3支持深层响应性​_vue.js

参考链接:

https://cn.vuejs.org/guide/essentials/reactivity-fundamentals.html