<template>
  <h1>个人信息：</h1>
  <h2>姓名：{{ person.name }}</h2>
  <h2>年龄：{{ person.age }}</h2>
  <button @click="test">触发showHelloMsg</button>
</template>

<script>
import {reactive} from "vue";

export default {
  name: 'Demo',
  beforeCreate() {
    console.log('---beforeCreate---')
  },
  props: ['msg', 'user'],
  emits: ['hello'],
  setup(props, context) {
    console.log('---setup---', context)  // $attrs $emits $slots
    console.log('---setup---', context.slots)  // $attrs $emits $slots
    let person = reactive({
      name: '张三',
      age: 18
    })

    function test() {
      context.emit('hello',666)
    }

    return {
      person,
      test
    }
  }
}
</script>
