sub-comp.vue 701 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <script setup lang="ts">
  2. import {
  3. onBeforeMount,
  4. onBeforeUnmount,
  5. onMounted,
  6. onUnmounted,
  7. useAttrs,
  8. watchEffect,
  9. } from 'vue/vapor'
  10. const props = defineProps<{
  11. foo: string
  12. bar: string
  13. baz: string
  14. }>()
  15. const attrs = useAttrs()
  16. watchEffect(() => {
  17. console.log({ ...attrs })
  18. })
  19. const keys = Object.keys
  20. onBeforeMount(() => console.log('sub: before mount'))
  21. onMounted(() => console.log('sub: mounted'))
  22. onBeforeUnmount(() => console.log('sub: before unmount'))
  23. onUnmounted(() => console.log('sub: unmounted'))
  24. </script>
  25. <template>
  26. <h2>sub-comp</h2>
  27. <p>
  28. props: {{ props }}
  29. <br />
  30. attrs: {{ attrs }}
  31. <br />
  32. keys(attrs): {{ keys(attrs) }}
  33. </p>
  34. </template>