Yb-components Yb-components
首页
开发规范
yb-cli
  • 开发指南
  • 更新日志
  • 组件
关于
首页
开发规范
yb-cli
  • 开发指南
  • 更新日志
  • 组件
关于
  • 开发指南
  • 更新日志
  • 数据展示

    • YbTable 表格
    • YbCardList 卡片列表
    • YbTree 树
    • YbCascaderList 级联列表
    • YbSimpleTablePage 分页查询表格
    • YbSimpleCardPage 分页卡片列表
    • YbBasicProfile 基础详情数据展示
    • YbOutscrollLayout 固定在滚动区域外
    • YbOutscrollTree 固定在滚动区域外的Tree
    • YbInfoLayout 信息页布局
    • YbEditLayout 编辑页布局
  • 数据录入

    • YbRowsPopoverForm 浮层多行表单
    • YbFormily 配置式表单
    • YbForm 表单
    • YbRowsForm 多行表单
    • YbCollapseForm 折叠表单
    • YbQueryFilter 筛选表单
    • YbFilesSelect 文件选择器
    • YbRangeWrapper 范围结构
    • YbRangeDatepicker 日期范围
    • YbRange 范围
    • YbFormulaInput 简单运算公式输入
    • YbCron 表达式生成器
    • YbTreeSelect 树型选择器
    • YbInputgroupWrapper 复合组
    • YbThemeSelect 主题风格选择器
    • YbSelect 选择器
    • YbPaginationSelect 分页选择器
    • YbCodemirror 代码编辑器
    • YbCodemirrorSql SQL编辑器
    • YbCodemirrorJson JSON编辑器
    • YbCodemirrorXml XML编辑器
    • YbCombiDatepicker 组合时间
    • YbQuarterPicker 季度选择器
    • YbRangeQuarterPicker 季度范围选择器
    • YbConditionSelect 条件选择器
    • YbCheckboxGroup 多选框组
    • YbIconSelect 选择器
    • YbTagsInput 标签输入框
  • 其他组件

    • YbBallLoading 加载中
    • YbSymbolIcon 多色小图标
    • YbKeybuttonsPopover
    • YbPercentBattery 电池百分比
    • YbAffix 固钉
    • YbPagination 分页器
    • YbCollapse 折叠面板
    • YbScrollTool 滚动工具
  • 物料

    • YbMainSideMenu 侧栏菜单
    • YbLoadRemote 远程应用加载
    • YbLayoutPro 布局
    • YbMainPro 主页
    • YbAppMain 应用主页
    • YbAppLogin 普通登录页
    • YbAppPortal Portal登录页
  • 指令

    • v-fixed-in-scroller
  • Mixins

    • pageList_mixin
    • getScopedSlot_mixin
      • 提供的 methods
    • editFormPage_mixin
    • uploadProgressPage_mixin
    • rowActions_mixin
    • rowDeletes_mixin
    • drawerToRouterTab_mixin
  • 实验室

    • YbSwiper 轮播
  • 组件
  • Mixins
zougt
2021-10-23

getScopedSlot_mixin

当组件使用的是 render 函数时,getScopedSlot_mixin 提供一些方法来定义作用域插槽和获取插槽的内容

# 需独立引入

import getScopedSlot_mixin from 'yb-components/packages/es/mixins/getScopedSlot_mixin';

export default {
    mixins: [getScopedSlot_mixin],
};
1
2
3
4
5

# 提供的 methods

# this.getScopedSlot(slotName)

从this.$scopedSlots获取作用域插槽函数的方法

  • 参数:

    • {string} slotName,插槽名称,支持格式:"title"、"title||titles"
  • 返回值:

    • {function} scopeSlot or null
  • 用法:

this.$scopedSlots 可能的情况是:

  1. {"title":function(data){return Node}}
  2. {"title,name":function(data){return Node}}
  3. {"titles":function(data){return Node}}

以上三种可能情况,都能获取到 titleSlot

import getScopedSlot_mixin from 'yb-components/packages/es/mixins/getScopedSlot_mixin';

export default {
    mixins: [getScopedSlot_mixin],
    render(h) {
        const titleSlot = this.getScopedSlot('title||titles');
        return titleSlot ? titleSlot({ data: 'a' }) : null;
    },
};
1
2
3
4
5
6
7
8
9

# this.getScopeSlotFromMult(slotName)

从this.$scopedSlots获取作用域插槽函数的方法

  • 参数:

    • {string} slotName,插槽名称,支持格式:"title"
  • 返回值:

    • {function} scopeSlot or null
  • 用法:

this.$scopedSlots 可能的情况是:

  1. {"title":function(data){return Node}}
  2. {"title,name":function(data){return Node}}

以上两种可能情况,都能获取到 titleSlot

import getScopedSlot_mixin from 'yb-components/packages/es/mixins/getScopedSlot_mixin';

export default {
    mixins: [getScopedSlot_mixin],
    render(h) {
        const titleSlot = this.getScopeSlotFromMult('title');
        return titleSlot ? titleSlot({ data: 'a' }) : null;
    },
};
1
2
3
4
5
6
7
8
9

# this.getScopedSlotValue(scopeSlot, [scopedData], [defaultNode])

调用 scopeSlot 函数得到插槽内容

  • 参数:

    • {function} scopeSlot,插槽函数
    • {object} [scopedData], 传入 scopeSlot 的参数
    • {string|number|vNode} [defaultNode],插槽函数没有返回值的默认内容
  • 返回值:

    • {string|number|vNode} scopeValue
  • 用法:

import getScopedSlot_mixin from 'yb-components/packages/es/mixins/getScopedSlot_mixin';

export default {
    mixins: [getScopedSlot_mixin],
    render(h) {
        const titleSlot = this.getScopedSlot('title');
        return this.getScopedSlotValue(titleSlot, { data: 'a' }, 'b');
    },
};
1
2
3
4
5
6
7
8
9
上次更新: 2022/05/22, 22:22:27
pageList_mixin
editFormPage_mixin

← pageList_mixin editFormPage_mixin→

Theme by Vdoing | Copyright © 2021-2025 YB-GZ | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式