ElementPlus Affix 固釘

2021-09-26 16:55 更新

Affix 固釘

將頁(yè)面元素固定在特定可視區(qū)域。

基本用法

固釘默認(rèn)固定在頁(yè)面頂部。


通過(guò)設(shè)置 offset 屬性來(lái)改變吸頂距離,默認(rèn)值為 0。

<template>
  <el-affix :offset="120">
  <el-button type="primary">距離頂部 120px</el-button>
</el-affix>
</template>

指定容器

通過(guò)設(shè)置 target 屬性,讓固釘始終保持在容器內(nèi),超過(guò)范圍則隱藏。


請(qǐng)注意容器避免出現(xiàn)滾動(dòng)條。

<template>
  <div class="affix-container">
  <el-affix target=".affix-container" :offset="80">
    <el-button type="primary">指定容器</el-button>
  </el-affix>
</div>
</template>

固定位置

Affix 組件提供了兩個(gè)固定位置:top 和 bottom。


通過(guò)設(shè)置 position 屬性來(lái)改變固定位置,默認(rèn)值為 top 。

<template>
  <el-affix position="bottom" :offset="20">
  <el-button type="primary">距離底部 20px</el-button>
</el-affix>
</template>

Attributes

參數(shù)說(shuō)明類型可選值默認(rèn)值
offset偏移距離number0
position固釘位置stringtop / bottomtop
target指定容器(CSS 選擇器)string
z-index固釘層級(jí)number100

Events

事件名稱說(shuō)明回調(diào)參數(shù)
change固釘狀態(tài)改變時(shí)觸發(fā)的事件(value: boolean)
scroll滾動(dòng)時(shí)觸發(fā)的事件滾動(dòng)距離和固釘狀態(tài)

Methods

方法名說(shuō)明參數(shù)
update手動(dòng)更新固釘狀態(tài)


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)