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

VueJs: Render a component inside another with scoped slots #8

Closed
inNetto opened this issue Jun 6, 2023 · 0 comments
Closed

VueJs: Render a component inside another with scoped slots #8

inNetto opened this issue Jun 6, 2023 · 0 comments
Assignees
Labels
VueJs VueJs Challenges

Comments

@inNetto
Copy link
Owner

inNetto commented Jun 6, 2023

  1. [VueJs] The challange is: As we built in issue Vue: Custom table reusable component #7, we need to improve our table to receive any html element inside our table in a new cell. For example: Our table just render the columns and data (th/td). But if the parent component needs the table render a edit button, or a delete or any html element else? If we define a button html inside the table, every table parent will render the button and that certainly is not the expected behavior if we are talking about a custom reusable table.

We can use scoped slot to implement our challange. Table define a named slot and the parent component just implement this named slot inside tag. Take a lock forward

image

The name of the slot is "actions" and needs to be used with the same name in parent component

image

As a scoped slot, the table pass a data inside the slot and then the parent can use this value inside his own template, not a global value. For more, take a look at entire solution on commit.

@inNetto inNetto self-assigned this Jun 6, 2023
@inNetto inNetto added the VueJs VueJs Challenges label Jun 6, 2023
@inNetto inNetto closed this as completed Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VueJs VueJs Challenges
Projects
None yet
Development

No branches or pull requests

1 participant