当前位置:网站首页>Slide the uniapp to a certain height and fix an element to the top effect demo (organize)
Slide the uniapp to a certain height and fix an element to the top effect demo (organize)
2022-07-06 22:34:00 【I'm happy】
After sliding tab Fixed to the top
<template>
<view class="topBox" :class="head==1?'topBoxStyle':''"> Test fixed top test fixed top </view>
</template>
<script>
export default {
data(){
return{
head: 0,
myScroll:0,
}
},
onLoad(e) {
// Get the distance from the target plate to the top
uni.createSelectorQuery().select('.topBox').boundingClientRect(res=>{
this.myScroll =res.top;
console.log(this.myScroll,'this.myScroll-------')
}).exec();
},
methods: {
onPageScroll(e){
// console.log(e,'eeeee')
if(e.scrollTop > this.myScroll){
this.temp= 1
}else{
this.temp= 0
}
},
}
}
</script>
<style>
.boxStyle{
width: 100%;
height: 80rpx;
position: fixed;
top: 0;
left: 0;
background: #fff;
}
</style>
边栏推荐
猜你喜欢
关于声子和热输运计算中BORN电荷和non-analytic修正的问题
[linear algebra] determinant of order 1.3 n
Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)
Leetcode exercise - Sword finger offer 26 Substructure of tree
uniapp滑动到一定的高度后固定某个元素到顶部效果demo(整理)
Web APIs DOM time object
Improving Multimodal Accuracy Through Modality Pre-training and Attention
Attack and defense world miscall
自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
【LeetCode】19、 删除链表的倒数第 N 个结点
随机推荐
Return keyword
Sword finger offer question brushing record 1
Mysql database basic operations DML
go多样化定时任务通用实现与封装
uniapp设置背景图效果demo(整理)
手写ABA遇到的坑
Use ECs to set up an agent
网络基础入门理解
TypeScript获取函数参数类型
Installation and use of labelimg
【踩坑合辑】Attempting to deserialize object on CUDA device+buff/cache占用过高+pad_sequence
Jafka来源分析——Processor
2014阿里巴巴web前实习生项目分析(1)
Inno Setup 打包及签名指南
机试刷题1
Volatile keyword
Adavit -- dynamic network with adaptive selection of computing structure
关于声子和热输运计算中BORN电荷和non-analytic修正的问题
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
Export MySQL table data in pure mode