Giter VIP home page Giter VIP logo

Comments (7)

rwu823 avatar rwu823 commented on April 27, 2024 7

@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>
    )
  }
}

from babel-plugin-transform-vue-jsx.

nickmessing avatar nickmessing commented on April 27, 2024 6

@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>
    )
  }
}

from babel-plugin-transform-vue-jsx.

ShuvoHabib avatar ShuvoHabib commented on April 27, 2024 1

{this.$slots.default}

from babel-plugin-transform-vue-jsx.

nadimtuhin avatar nadimtuhin commented on April 27, 2024

any update?

from babel-plugin-transform-vue-jsx.

blade254353074 avatar blade254353074 commented on April 27, 2024

https://vuejs.org/guide/render-function.html#Functional-Components
https://vuejs.org/api/#vm-slots

from babel-plugin-transform-vue-jsx.

yyx990803 avatar yyx990803 commented on April 27, 2024

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

from babel-plugin-transform-vue-jsx.

Maxim-Mazurok avatar Maxim-Mazurok commented on April 27, 2024

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>

from babel-plugin-transform-vue-jsx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.