当前位置:网站首页>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
边栏推荐
- nexus搭建npm依赖私库
- During Oracle CDC data transmission, the CLOB type field will lose its value during update. There is a value before update, but
- c语言学习
- Beidou communication module Beidou GPS module Beidou communication terminal DTU
- 软件测试中功能测试流程
- Report on the 14th five year plan and future development trend of China's integrated circuit packaging industry Ⓓ 2022 ~ 2028
- Project deployment is not difficult at all!
- Jenkins+webhooks-多分支参数化构建-
- How to play with the reading and writing operations of blocking sockets?
- Use of shutter SQLite
猜你喜欢

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

Google Earth engine (GEE) - Global Human Settlements grid data 1975-1990-2000-2014 (p2016)

【开发大杀器】之Idea

Nexus builds NPM dependent private database

内容审计技术

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

Fiori applications are shared through the enhancement of adaptation project

JS变色的乐高积木

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

The future of game guild in decentralized games
随机推荐
MHA high availability cluster deployment and failover of database
[Niu Ke's questions -sql big factory interview real questions] no2 User growth scenario (a certain degree of information flow)
终端识别技术和管理技术
VM虚拟机配置动态ip和静态ip访问
机器学习—性能度量
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
Report on the "14th five year plan" and investment strategy recommendations for China's industrial robot industry 2022 ~ 2028
How can genetic testing help patients fight disease?
Scene function of wooden frame
VM virtual machine configuration dynamic IP and static IP access
Asp. NETCORE uses dynamic to simplify database access
逆向调试入门-PE结构-输入表输出表05/07
[development of large e-commerce projects] performance pressure test - basic concept of pressure test & jmeter-38
Operator-1 first acquaintance with operator
Shell script imports stored procedures into the database
Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
Report on the 14th five year plan and future development trend of China's integrated circuit packaging industry Ⓓ 2022 ~ 2028
Detailed explanation of parallel replication examples in MySQL replication
Three questions about scientific entrepreneurship: timing, pain points and important decisions