reactive函数

<template>
  <div>
    <h1>vue3</h1>
    <span>{{info.name}} - {{info.age}}</span>
    <button @click="infobtn">修改info</button>
  </div>
</template>

<script>
import {reactive} from 'vue'
export default {
  setup(){
    // 数据 : reactive只能是复杂类型
    const info = reactive({
      name:'吴宇腾',
      age:18
    })
    // 事件
    const infobtn = ()=>{
      info.name = '海贼王',
      info.age = 1999
    }
    return {
      info,
      infobtn
    }
  }
}
</script>

 

posted @ 2022-08-24 09:54  杨建鑫  阅读(18)  评论(0编辑  收藏  举报