From 20827a1da0db1bce02767505fa1c0a77cd25ba62 Mon Sep 17 00:00:00 2001 From: Cristiano Magro <cristiano.magro@vola.it> Date: Sun, 05 Jan 2025 17:37:27 +0100 Subject: [PATCH] gestione slot non valorizzato --- 09 - deeper into components/cmp-adv-01-starting-setup/src/components/BaseCard.vue | 25 +++++++++++++++---------- 1 files changed, 15 insertions(+), 10 deletions(-) diff --git a/09 - deeper into components/cmp-adv-01-starting-setup/src/components/BaseCard.vue b/09 - deeper into components/cmp-adv-01-starting-setup/src/components/BaseCard.vue index 2aeb46b..a6f355d 100644 --- a/09 - deeper into components/cmp-adv-01-starting-setup/src/components/BaseCard.vue +++ b/09 - deeper into components/cmp-adv-01-starting-setup/src/components/BaseCard.vue @@ -1,7 +1,9 @@ <template> <div> - <header> - <slot name="header"></slot> + <header v-if="$slots.header"> + <slot name="header"> + <!-- <h2>Default Title </h2> --> + </slot> </header> <slot></slot> </div> @@ -9,22 +11,25 @@ <script> export default { + mounted() { + console.log(this.$slots); + } } </script> <style scoped> div { - margin: 2rem auto; - max-width: 30rem; - border-radius: 12px; - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); - padding: 1rem; + margin: 2rem auto; + max-width: 30rem; + border-radius: 12px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); + padding: 1rem; } section header { - display: flex; - justify-content: space-between; - align-items: center; + display: flex; + justify-content: space-between; + align-items: center; } </style> \ No newline at end of file -- Gitblit v1.8.0