当前位置:网站首页>9. Use of better scroll and ref
9. Use of better scroll and ref
2022-07-01 13:15:00 【Justion_】
Solve some problems
h5 The layout of the whole complex element needs to add one 100% The width of vw Dead height vh Use elastic boxes , head , At the end of bar Fix .
Header and Home page Delete the fixed positioning inside
position: fixed;
top: 0;
left: 0;.ly-tab {
position: fixed;
top: 1.2rem;
left: 0;
} And then in Home Middle feeding
Add a fixed positioning


to .home 

swiper In the component margin-top: 2.5rem; Delete
stay home page section Add margin-top: 2.5rem;
tabbr Remove the fixed position of

install better-scroll
cnpm i better-scroll -S
home Page in import.......
<template>
<div class="home">
<div class="headers">
<div class="headers-main">
<Header />
<ly-tab v-model="selectedId" :items="items" :options="options">
</ly-tab>
</div>
</div>
<section ref="wrapper">
<div>
<Swiper />
<Icons />
<Recommend />
</div>
</section>
<Tabbar />
</div>
</template>
<script>
import Tabbar from "@/components/common/Tabbar.vue";
import Header from "@/components/home/Header.vue";
import Swiper from "@/components/home/Swiper";
import Icons from "@/components/home/Icons";
// introduce better-scroll
import BetterScorll from "better-scroll";
import Recommend from "@/components/home/Recommend";
export default {
components: {
Tabbar,
Header,
Swiper,
Icons,
Recommend,
},
name: "Home",
mounted() {
// console.log(this.$data, this.$el);
new BetterScorll(this.$refs.wrapper, {
movable: true,
zoom: true,
});
},
data() {
return {
selectedId: 0,
items: [
{ label: " home page " },
{ label: " Big red tea " },
{ label: " Red tea " },
{ label: " Green tea " },
{ label: " Black tea " },
{ label: " Blue tea " },
{ label: " Tea set " },
{ label: " Design " },
],
options: {
activeColor: "#4ac23f",
// You can specify here labelKey For the field corresponding to the text in your data
},
};
},
};
</script>
<style scoped>
.home {
display: flex;
flex-direction: column;
width: 100vw;
height: 100vh;
overflow: hidden;
}
.headers {
width: 100%;
height: 0.3rem;
}
.headers-main {
position: fixed;
top: 0;
left: 0;
}
section {
flex: 1;
margin-top: 2.5rem;
overflow: hidden;
}
::v-deep .ly-tab {
box-shadow: none;
border-bottom: none;
}
</style>
Effect scrolling effect :

Sub element height Higher than the height of the parent element , Must be added to mounted in
vue Medium ref
obtain dom
Set up :<div ref="justion"></div>
obtain :this.$refs.justion
边栏推荐
- Analysis report on the development prospect and investment strategy of the global and Chinese laser chip industry Ⓑ 2022 ~ 2027
- 声明一个抽象类Vehicle,它包含私有变量numOfWheels和公共函数Vehicle(int)、Horn()、setNumOfWheels(int)和getNumOfWheels()。子类Mot
- Function test process in software testing
- Feign & Eureka & zuul & hystrix process
- Application of 5g industrial gateway in scientific and technological overload control; off-site joint law enforcement for over limit, overweight and overspeed
- How to play with the reading and writing operations of blocking sockets?
- 王兴的无限游戏迎来“终极”一战
- JS变色的乐高积木
- C language learning
- Flutter SQLite使用
猜你喜欢

Judea pearl, Turing prize winner: 19 causal inference papers worth reading recently

nexus搭建npm依赖私库

数据库之MHA高可用集群部署及故障切换

Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS

The future of game guild in decentralized games

Fiori 应用通过 Adaptation Project 的增强方式分享

Jenkins+webhooks-多分支参数化构建-

Shell script imports stored procedures into the database

JS变色的乐高积木

Terminal identification technology and management technology
随机推荐
Report on the 14th five year plan and future development trend of China's integrated circuit packaging industry Ⓓ 2022 ~ 2028
一款Flutter版的记事本
PG basics -- Logical Structure Management (trigger)
基于mysql乐观锁实现秒杀的示例代码
JS变色的乐高积木
Analysis report on the development trend and prospect scale of silicon intermediary industry in the world and China Ⓩ 2022 ~ 2027
Run PowerShell script prompt "because running script is prohibited on this system" solution
Redis exploration: cache breakdown, cache avalanche, cache penetration
Yarn重启applications记录恢复
流量管理技术
Ustime wrote a bug
Jenkins+webhooks-多分支参数化构建-
Detailed explanation of OSPF LSA of routing Foundation
Judea pearl, Turing prize winner: 19 causal inference papers worth reading recently
CS5268优势替代AG9321MCQ Typec多合一扩展坞方案
Router. use() requires a middleware function but got a Object
机器学习—性能度量
Zabbix 6.0 源码安装以及 HA 配置
VM虚拟机配置动态ip和静态ip访问
有没有大佬 遇到过flink监控postgresql数据库, 检查点无法使用的问题