ref函数浅层解包

<template>
  <div>
    <h1>浅层解包</h1>
    {{ageobj.age.value}} ---  {{ageobj.age}}
    <button @click="ageobj.age.value++ ">修改浅层解包的年龄</button>
  </div>
</template>

<script>
import {ref} from 'vue'
export default {
  setup(){
    const age = ref(29)

    const ageobj = {
      age
    }
    return {
      ageobj
    }
  }
}
</script>

 

posted @ 2022-08-24 10:26  杨建鑫  阅读(59)  评论(0编辑  收藏  举报