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

Supported slot from Component's inside? #19

Closed
rwu823 opened this issue Aug 19, 2016 · 7 comments
Closed

Supported slot from Component's inside? #19

rwu823 opened this issue Aug 19, 2016 · 7 comments

Comments

@rwu823
Copy link

rwu823 commented Aug 19, 2016

In some nested components case, we don't want to pass slot from outside, cloud we defined in component first?

const Compo = {
  render(h) {
    return (
      <div slot="foo">

      </div> 
    )
  }
}
@nadimtuhin
Copy link

any update?

@ShuvoHabib
Copy link

{this.$slots.default}

@yyx990803
Copy link
Member

I'm not sure if I understand the original request...

@rwu823
Copy link
Author

rwu823 commented Nov 18, 2016

@yyx990803

For example normal slot usage:

<Tab>
  <TabHead slot="tabhead">
    ...
  </TabHead>
</Tab>

Expect defining from component's inside as well:

// TabHead.js
const TabHead = {
  name: 'TabHead',
  render(h) { 
    return(
      <div slot="tabhead">
         ...
      </div>
    )
  }
}

@nickmessing
Copy link
Member

nickmessing commented Jul 10, 2017

@rwu823, you can achieve that by doing:

export default {
  render () {
    return (
      <div>
        {this.$slots.tabhead
          ? <this.$slots.tabhead />
          : <h1>Your content here</h1>} 
      </div>
    )
  }
}

instead of:

export default {
  render () {
    return (
      <div slot="tabhead">
        <h1>Your content here</h1>
      </div>
    )
  }
}

@Maxim-Mazurok
Copy link

Maxim-Mazurok commented Apr 1, 2021

Wow, that actually worked!

I was trying to do this:

<VBreadcrumbs
  class={{ "pl-0": true, [breadcrumbsStyle.root]: true }}
  scopedSlots={{
    item: ({ item }) => (
      <VBreadcrumbsItem>
        <VBtn
          link
          elevation={0}
          small
          color="transparent"
          class="px-2"
          onClick={() => {
            console.log(item);
          }}
        >
          {item.text}
        </VBtn>
      </VBreadcrumbsItem>
    ),
  }}
  slots={{
    divider: () => [<VIcon>{mdiChevronRight}</VIcon>],
  }}
  items={this.breadcrumbs}
>
</VBreadcrumbs>

But this actually worked:

<VBreadcrumbs
  class={{ "pl-0": true, [breadcrumbsStyle.root]: true }}
  // divider={<VIcon>{mdiChevronRight}</VIcon>}
  scopedSlots={{
    item: ({ item }) => (
      <VBreadcrumbsItem>
        <VBtn
          link
          elevation={0}
          small
          color="transparent"
          class="px-2"
          onClick={() => {
            console.log(item);
          }}
        >
          {item.text}
        </VBtn>
      </VBreadcrumbsItem>
    ),
  }}
  items={this.breadcrumbs}
>
  <div slot="divider">
    <VIcon>{mdiChevronRight}</VIcon>
  </div>
</VBreadcrumbs>

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

No branches or pull requests

7 participants