zheng 23 hours ago
parent
commit
ed5a3999db

+ 6 - 2
16.vue3/project3/src/views/Custom/Father.vue

@@ -1,17 +1,21 @@
 <template>
   <div>
     <h1 class="h-26 text-6xl">Custom</h1>
-    <h3 class="h-16 text-4xl"></h3>
+    <h3 class="h-16 text-4xl">子组件给了我{{ flower }}朵花</h3>
     <hr class="h-15" />
     <hr class="h-15" />
     <hr class="h-15" />
-    <Child></Child>
+    <Child @send="addThing"></Child>
   </div>
 </template>
 
 <script lang="ts" setup>
 import { ref, reactive } from "vue";
 import Child from "./index.vue";
+let flower = ref<number>(0);
+const addThing = () => {
+  flower.value += 1;
+};
 </script>
 
 <style lang="scss" scoped>

+ 2 - 0
16.vue3/project3/src/views/Custom/index.vue

@@ -1,11 +1,13 @@
 <template>
   <div>
     <h1 class="h-26 text-6xl">子组件</h1>
+    <button @click="emits('send')">展示</button>
   </div>
 </template>
 
 <script lang="ts" setup>
 import { ref, reactive } from "vue";
+const emits = defineEmits("send");
 </script>
 
 <style lang="scss" scoped>