
<template><demo msg="你好啊" @hello="handleHello"><template v-slot:hahaha><span>哈哈哈</span></template></demo></template><script>import Demofrom"./components/Demo.vue"exportdefault{name:'App',components:{
Demo},setup(){functionhandleHello(value){
console.log(value);}return{
handleHello}}}</script>
<template><div>{{person.name}}</div><div>{{person.sex}}</div><div>{{person.hobby}}</div><button @click="test">点我</button><br><slot name="hahaha"></slot></template><script>import{reactive}from'vue'exportdefault{name:'Demo',props:['msg'],emits:['hello'],setup(props, context){
console.log(props);
console.log(context.attrs);
console.log(context.slots);let person=reactive({name:'may',sex:'女'})functiontest(){
context.emit('hello','888')}return{
person,
test}}}</script>