vue4例子

<template>
   <div class="person"></div>
   <h2>姓名{{ person.name }}</h2>
   <h2>年龄{{ person.age }}</h2>
   <button @click="changeage">修改</button>
</template>

<script lang="ts" setup name="person">
import { reactive } from "vue";

let person = reactive ({
   name:'zhangsan',
   age:20
})

function changeage(){
   person.age += 1
}
</script>

<style scoped>
</style>

  

posted @ 2025-03-05 15:36  华腾智算  阅读(10)  评论(0)    收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL