Files
FirstUI-vue/pages/component/nav/sticky-A/sticky-A.vue
2023-08-17 21:28:49 +08:00

101 lines
2.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--本文件由FirstUI授权予新疆天衡创新研究院有限公司手机号 1 86 1 40 72 54 9身份证尾号5A07X5专用请尊重知识产权勿私下传播违者追究法律责任-->
<template>
<view class="fui-wrap">
<view class="fui-page__hd">
<view class="fui-page__title fui-align__center" @tap="vip">Sticky <image
src="/static/images/index/light/icon_member_3x.png"></image>
</view>
<view class="fui-page__desc">Sticky 吸顶容器用于将标题栏在滚动时固定到页面顶部</view>
</view>
<view class="fui-section__title">放置根目录下</view>
<fui-sticky :zIndex="1001" :scrollTop="scrollTop">
<view class="fui-header">滑动页面查看效果</view>
</fui-sticky>
<view class="fui-seat__wrap">
温馨提示组件父元素不能使用overflow:hidden或者overflow:auto属性且父元素的高度不能低于sticky元素的高度
</view>
<view class="fui-section__title">放置scroll-view内</view>
<scroll-view scroll-y class="fui-scroll__view">
<view style="height: 800px;position: relative;">
<view class="fui-seat__wrap" style="height: 70px;">
温馨提示组件父元素不能使用overflow:hidden或者overflow:auto属性且父元素的高度不能低于sticky元素的高度
</view>
<!--scroll-view 内组件不需要传值 scrollTop -->
<fui-sticky>
<view class="fui-header">滑动scroll-view查看效果</view>
</fui-sticky>
<view class="fui-seat__wrap" style="height: 40px;">
注意sticky组件如果放在scroll-view根目录下当到scroll-view元素的底部时sticky效果会失效
</view>
<view class="fui-seat__wrap">
解决办法如当scroll-view的高度为200px但是scrollHeight为800px在scroll-view中嵌套一个view就能顺利定位</view>
<view class="fui-footer">到达底部</view>
</view>
</scroll-view>
<view style="height: 800px;"></view>
</view>
</template>
<script>
export default {
data() {
return {
scrollTop: 0
}
},
// #ifdef MP-QQ || MP-TOUTIAO || MP-BAIDU
onPageScroll(e) {
// console.log(e)
this.scrollTop = e.scrollTop
},
// #endif
methods: {
vip() {
this.fui.href("/pages/my/qa/qa?index=2&title=VIP专属内容")
}
}
}
</script>
<style>
page {
font-weight: normal;
}
.fui-section__title {
margin-left: 32rpx;
margin-top: 48rpx;
}
.fui-header {
width: 100%;
padding: 24rpx;
box-sizing: border-box;
display: flex;
justify-content: center;
background: #F8F8F8;
color: #465CFF;
font-weight: bold;
}
.fui-seat__wrap,
.fui-footer {
height: 60px;
font-size: 24rpx;
color: #B2B2B2;
padding: 32rpx;
box-sizing: border-box;
}
.fui-footer {
position: absolute;
left: 0;
bottom: 0;
}
.fui-scroll__view {
width: 100%;
height: 200px;
background: #fff;
}
</style>