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
      • editFormPage_mixin
      • uploadProgressPage_mixin
      • rowActions_mixin
      • rowDeletes_mixin
      • drawerToRouterTab_mixin
    • 实验室

      • YbSwiper 轮播
    • 组件
    • 其他组件
    liaoyingmin
    2022-10-21

    YbAffix 固钉

    将页面元素固定在特定可视区域。组件中自带节流器(300ms)

    # 基础用法

    <template>
        <yb-affix :offset="58">
            <template v-slot>
                <el-button type="primary" size="mini">Affix top 58px</el-button>
            </template>
        </yb-affix>
    </template>
    
    1
    2
    3
    4
    5
    6
    7
    显示 复制 复制

    # 固定在滚动元素内

    <template>
        <div style="overflow:auto;height:500px;position:relative;">
            <div style="height:2000px"></div>
            <yb-affix
                :offset="0"
                position="bottom"
                isClosestScrollTarget
                isShowBackground
            >
                <template v-slot>
                    <el-button type="primary" size="mini">Affix bottom</el-button>
                </template>
            </yb-affix>
        </div>
    </template>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    显示 复制 复制

    # 固定在目标容器

    <template>
        <div class="affix-container">
            <yb-affix
                :offset="0"
                target=".affix-container"
                padding="20px 0 30px 0"
                isShowBackground
            >
                <template v-slot>
                    <el-button type="primary" size="mini">Target</el-button>
                </template>
            </yb-affix>
            <!-- <yb-affix
                ref="affix"
                :offset="0"
                :target="getContainer"
                padding="20px 0 30px 0"
                isShowBackground
            >
                <template v-slot>
                    <el-button type="primary" size="mini">Target</el-button>
                </template>
            </yb-affix> -->
        </div>
    </template>
    <script>
        export default {
            methods: {
                getContainer() {
                    return this.$refs.affix.$el.parentElement;
                },
            },
        };
    </script>
    <style>
        .affix-container {
            text-align: center;
            height: 900px;
            border-radius: 4px;
            background: #ecf5ff;
            padding: 20px;
        }
    </style>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    显示 复制 复制

    # 指定位置

    <template>
        <yb-affix
            :offset="100"
            position="bottom"
            padding="20px 0 30px 0"
            isShowBackground
            :isFullBackground="false"
        >
            <el-button type="primary" size="mini">Affix bottom 100px</el-button>
        </yb-affix>
    </template>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    显示 复制 复制

    # 最近滚动元素

    • 元素的样式属性overflow、overflow-y的值设置为auto或scroll,将作为滚动元素
    <template>
        <div class="affix-container">
            <yb-affix
                :offset="0"
                target=".affix-container"
                isShowBackground
                :isFullBackground="false"
                isClosestScrollTarget
            >
                <template v-slot>
                    <el-button type="primary" size="mini" style="margin:10px 0">
                        Target
                    </el-button>
                </template>
            </yb-affix>
            <div ref="height"></div>
        </div>
    </template>
    <script>
        export default {
            mounted() {
                setTimeout(() => {
                    this.$refs.height.style.height = '1200px';
                }, 2000);
            },
        };
    </script>
    <style>
        .affix-container {
            text-align: center;
            height: 900px;
            border-radius: 4px;
            background: #ecf5ff;
            padding: 20px;
            overflow: auto; /**/
        }
    </style>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    显示 复制 复制

    # YbAffix Attributes

    参数 说明 类型 可选值 默认值
    offset 偏移距离 number -- 0
    position 位置 string 'top' | 'bottom' 'top'
    target 指定容器 (CSS 选择器),函数使用方式详见指定容器 string | function(scrollEL){return dom} -- --
    z-index 设置时优先级最高。未设置时,取样式中的 zIndex,若样式未设置 zIndex,默认设置 100 number -- --
    isShowBackground 浮动时是否自动显示背景 boolean -- false
    isFullBackground 是否背景充满整个 target,在 isShowBackground 为 true 时生效 boolean -- true
    isClosestScrollTarget 是否将最近的可能滚动元素作为监听的滚动元素 boolean -- false
    padding 浮动时内边距(遵循 top right bottom left),在 is-full-background 为 true 时生效,设置后以设置的值为准,组件内部自动计算的 paddingLeft 和 paddingRight 将失效 , 也可以用占位符引用内部计算的 paddingLeft 和 paddingRight: '4px ${right} 4px ${left}' string -- --
    background 浮动时背景,不设置则为透明,在 isShowBackground 为 true 时生效 string -- 'white'

    # YbAffix Scoped Slot

    name 说明
    default 自定义默认内容

    # YbAffix Methods

    方法名称 说明
    updatePosition 手动更新位置信息
    上次更新: 2025/02/17, 14:19:42
    YbPercentBattery 电池百分比
    YbPagination 分页器

    ← YbPercentBattery 电池百分比 YbPagination 分页器→

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