Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to improve Dynamic Slot Names documentation #3038

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dtechmaster
Copy link

Sure! Here's a suggested pull request message that you can use:


Title: Improve Documentation for Dynamic Slot Names by Adding Declaration Examples

Description:

This pull request enhances the Dynamic Slot Names section of the Vue.js documentation by providing explanations and examples on how to declare dynamic slots in child components, not just how to use them in parent components.


Description of Problem

The current documentation for Dynamic Slot Names focuses primarily on how to use dynamic slot names in the parent component using v-slot with dynamic arguments. It lacks information on how to declare dynamic slots in the child component. This omission can lead to confusion, as understanding both declaration and usage is essential for implementing dynamic slots effectively.

Proposed Solution

  • Added Explanation: Introduced a subsection that explains how to declare dynamic slots in child components using the :name binding on the <slot> element.
  • Examples with Composition API: Provided examples using <script setup> and the Composition API to align with modern Vue.js practices.
  • Static and Dynamic Usage: Illustrated both static and dynamic ways of providing slot content in parent components.
  • Practical Example: Included a practical example that mirrors common use cases, making it easier for developers to understand and implement dynamic slots.
  • Important Notes: Highlighted crucial points such as matching slot names between parent and child components and handling fallback content.

Additional Information

  • Consistency: Ensured that the new content follows the existing documentation style and guidelines.
  • Clarity: Kept explanations concise to maintain readability while providing enough detail for comprehension.
  • Reusability: The examples can be easily adapted by developers for their own projects.

Propose explanation on how to declare Dynamic Slot Names and not only on how to use them.
Copy link

netlify bot commented Sep 26, 2024

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit e7e5e7d
🔍 Latest deploy log https://app.netlify.com/sites/vuejs/deploys/66f512b0435f1c0008c587b5
😎 Deploy Preview https://deploy-preview-3038--vuejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

</ChildComponent>
</template>

<script setup>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: we need to wrap this in <div class="composition-api"></div> and write the matching code for Options API

<script setup>
import ChildComponent from './ChildComponent.vue';

const slotNames = ['header', 'footer'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note as above about the Options API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants