Affix 固钉
将页面元素钉在可视范围,常用于侧边菜单和按钮组合。 当内容区域比较长,需要滚动页面时,这部分内容对应的操作或者导航需要在滚动范围内始终展现。
假装页面很高
 查看代码 < />
<template>
  <w-affix :offsetTop="80">
    <w-button>大家好,我是一个顶部固钉</w-button>
  </w-affix>
  <div class="div-container">
    假装页面很高
  </div>
  <w-affix :onAffix="fixedChange" :offsetBottom="0">
    <w-button>Hi,我是一个底部固钉</w-button>
  </w-affix>
</template>
<script>
  export default {
    methods:{
      fixedChange (status) {
        console.log('当前状态'+ status)
      },
      scrollTop () {
        window.scrollTo(0, 600)
      }
    }
  }
</script>
<style scoped lang="scss">
  .div-container {
    display: inline-block;
    margin: 10px 0;
    width: 100%;
    background: #e0e0e0;
    border-radius: 10px;
    color: #999;
    height: 1000px;
    text-align: center;
    line-height: 1000px;
    font-size: 40px;
  }
</style>API
Options
| 参数 | 说明 | 类型 | 默认值 | Version | 
|---|---|---|---|---|
| offsetBottom | 距离窗口底部达到指定偏移量后触发 | number | — | |
| offsetTop | 距离窗口顶部达到指定偏移量后触发 | number | — | |
| onAffix | 固定状态改变时触发的回调函数 | function(affixed) | — | 
贡献者
| 类型 | 参与者 | 
|---|---|
| 设计者 | UED视觉组 | 
| 维护者 | UED前端组 |