<template>
  <div>
    <h1 class="h-26 text-6xl">子组件2</h1>
    <h3 class="text-2xl h-12">兄弟给了我{{ num }}元</h3>
  </div>
</template>

<script lang="ts" setup>
import emitter from "@/utils/emitter.js";
import { ref, reactive, onUnmounted } from "vue";
let num = ref(0);
// 方法 监听
emitter.on("xxx", (val: number) => {
  num.value += val;
});
onUnmounted(() => {
  emitter.off("xxx");
});
</script>

<style lang="scss" scoped>
</style>
