当前位置:网站首页>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
边栏推荐
- 软件测试中功能测试流程
- 有人碰到过这种情况吗,oracle logminer 同步的时候,clob字段的值丢失
- Vs code set code auto save
- How to play with the reading and writing operations of blocking sockets?
- Asp. NETCORE uses dynamic to simplify database access
- Development trend and market demand analysis report of China's high purity copper industry Ⓕ 2022 ~ 2028
- Tencent always takes epoll, which is annoying
- Ikvm of toolbox Net project new progress
- Manage nodejs with NVM (downgrade the high version to the low version)
- PG基础篇--逻辑结构管理(触发器)
猜你喜欢

A Fletter version of Notepad

【大型电商项目开发】性能压测-压力测试基本概念&JMeter-38

5G工业网关的科技治超应用 超限超重超速非现场联合执法

What is the future development direction of people with ordinary education, appearance and family background? The career planning after 00 has been made clear

Content Audit Technology

路由基础之OSPF LSA详细讲解

Terminal identification technology and management technology

Meta再放大招!VR新模型登CVPR Oral:像人一样「读」懂语音

Cs5268 advantages replace ag9321mcq typec multi in one docking station scheme

Meta enlarge again! VR new model posted on CVPR oral: read and understand voice like a human
随机推荐
Yarn restart applications record recovery
软件测试中功能测试流程
The popular major I chose became "Tiankeng" four years later
Will it affect the original MySQL database to read the data of a MySQL table in full by flick MySQL CDC
flinkcdc要实时抽取oracle,对oracle要配置什么东西?
Detailed explanation of OSPF LSA of routing Foundation
逆向调试入门-PE结构-输入表输出表05/07
Function test process in software testing
Analysis report on the development trend and Prospect of new ceramic materials in the world and China Ⓐ 2022 ~ 2027
oracle cdc 数据传输时,clob类型字段,在update时值会丢失,update前有值,但
When Sqlalchemy deletes records with foreign key constraints, the foreign key constraints do not work. What is the solution?
Router. use() requires a middleware function but got a Object
Use of shutter SQLite
Colorful five pointed star SVG dynamic web page background JS special effect
Have you ever encountered the problem that flynk monitors the PostgreSQL database and checkpoints cannot be used
Idea of [developing killer]
In the next stage of digital transformation, digital twin manufacturer Youyi technology announced that it had completed a financing of more than 300 million yuan
王兴的无限游戏迎来“终极”一战
Ikvm of toolbox Net project new progress
Report on the "14th five year plan" and investment strategy recommendations for China's industrial robot industry 2022 ~ 2028