Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

Functions

Type aliases

Slots

Slots: Record<string, NormalizedScopedSlot>

Functions

renderSlot

  • renderSlot(slots: Slots, name: string, props: Record<string, unknown>, fallback: NormalizedScopedSlot): ScopedSlotReturnValue | void
  • 插槽渲染函数

    renderSlot 是个辅助函数,支持在 vue 的 jsx 中使用

    example
    import { defineComponent, renderSlot } from '@zhengxs/composition-api'
    
    export default defineComponent({
      setup(props, { slots }) {
    
        return (h) => {
          const children = renderSlot(slots, 'default', {}, () => {
             return [h('span', 'hello,world')]
          })
    
          // 目前不支持 vue 的 jsx 语法
          return h('div', children)
        }
      }
    })
    

    Parameters

    • slots: Slots

      作用域插槽

    • name: string

      插槽名称

    • props: Record<string, unknown>

      参数

    • fallback: NormalizedScopedSlot

      如果 slot 不存在就调用

    Returns ScopedSlotReturnValue | void

    虚拟节点列表