vue监听div滚动条下拉刷新数据,vue滚动条回到最顶部,vue计算div宽度
分类: vue 专栏: vue 标签: div滚动到底部 div滚动事件 vue滚动条回到最顶部 vue计算div宽度 设置div滚动条样式
2024-01-18 14:13:43 1113浏览
vue如何给div加滚动监听,div固定高度,内容超出自动加滚动条
loading=false;
<div class="leftdivmain" @scroll="scrollShopPage($event)">
</div>
.leftdivmain {
height: calc(100vh - 70px);
overflow: auto;
margin-top: 20px;
}
.leftdivmain::-webkit-scrollbar { /*滚动条整体样式*/
width: 10px; /*高宽分别对应横竖滚动条的尺寸*/
height: 5px;
}
.leftdivmain::-webkit-scrollbar-thumb { /*滚动条里面小方块*/
border-radius: 10px;
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: #dddddd;
}
.leftdivmain::-webkit-scrollbar-track { /*滚动条里面轨道*/
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
border-radius: 10px;
background: #EDEDED;
}
scrollShopPage(e){
if(!this.loading){//避免下拉重复刷新页面
if(e.srcElement.scrollTop+e.srcElement.offsetHeight>e.srcElement.scrollHeight-100){
this.squery.pageNo++;
this.getGoodsPage();
}
}
},
this.$refs.goodsitemsdiv.scrollTop=0;//回到最顶部
this.gitemWidth = this.$refs.goodsitemsdiv.clientWidth/5-10;//计算div宽度
ref="goodsitemsdiv"
getGoodsPage() {
//一定要设为true,避免下拉重复刷新页面
this.goodsLoading=true;
this.goodsMore = "数据请求中...";
this.goodsQuery.uid = this.lander.uid;
this.goodsQuery.token = this.lander.token;
front_goods(this.goodsQuery).then((res) => {
this.goodsLoading=false;//-------
}).catch(() => {
this.goodsLoading=false;
this.$message.info('发送请求失败,请检查网络或重试');
});
},
好博客就要一起分享哦!分享海报
此处可发布评论
评论(0)展开评论
暂无评论,快来写一下吧
展开评论
他的专栏
他感兴趣的技术

java
vue
springboot
Mysql
ssm
小程序
uniapp
js和jquery