W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
將頁面元素固定在特定可視區(qū)域。
固釘默認固定在頁面頂部。
通過設置 offset 屬性來改變吸頂距離,默認值為 0。
<template>
<el-affix :offset="120">
<el-button type="primary">距離頂部 120px</el-button>
</el-affix>
</template>
通過設置 target 屬性,讓固釘始終保持在容器內,超過范圍則隱藏。
請注意容器避免出現(xiàn)滾動條。
<template>
<div class="affix-container">
<el-affix target=".affix-container" :offset="80">
<el-button type="primary">指定容器</el-button>
</el-affix>
</div>
</template>
Affix 組件提供了兩個固定位置:top 和 bottom。
通過設置 position 屬性來改變固定位置,默認值為 top 。
<template>
<el-affix position="bottom" :offset="20">
<el-button type="primary">距離底部 20px</el-button>
</el-affix>
</template>
參數(shù) | 說明 | 類型 | 可選值 | 默認值 |
---|---|---|---|---|
offset | 偏移距離 | number | — | 0 |
position | 固釘位置 | string | top / bottom | top |
target | 指定容器(CSS 選擇器) | string | — | — |
z-index | 固釘層級 | number | — | 100 |
事件名稱 | 說明 | 回調參數(shù) |
---|---|---|
change | 固釘狀態(tài)改變時觸發(fā)的事件 | (value: boolean) |
scroll | 滾動時觸發(fā)的事件 | 滾動距離和固釘狀態(tài) |
方法名 | 說明 | 參數(shù) |
---|---|---|
update | 手動更新固釘狀態(tài) | — |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: