当前位置:网站首页>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
边栏推荐
- SSO and JWT good article sorting
- Investment analysis and prospect prediction report of global and Chinese dimethyl sulfoxide industry Ⓦ 2022 ~ 2028
- mysql统计账单信息(下):数据导入及查询
- MySQL Replication中的并行复制示例详解
- 有人碰到过这种情况吗,oracle logminer 同步的时候,clob字段的值丢失
- 有没有大佬 遇到过flink监控postgresql数据库, 检查点无法使用的问题
- 一款Flutter版的记事本
- MHA high availability cluster deployment and failover of database
- shell脚本导入存储过程到数据库
- C language learning
猜你喜欢

我选的热门专业,四年后成了“天坑”
MySQL报错1040Too many connections的原因以及解决方案

Professor Li Zexiang, Hong Kong University of science and technology: I'm wrong. Why is engineering consciousness more important than the best university?
Example code of second kill based on MySQL optimistic lock

啟動solr報錯The stack size specified is too small,Specify at least 328k

Content Audit Technology

Colorful five pointed star SVG dynamic web page background JS special effect
![Idea of [developing killer]](/img/74/f4a18afd2b86373996e4ca62b50f88.png)
Idea of [developing killer]

Different test techniques

ROS2 Foxy depthai_ ROS tutorial
随机推荐
Beidou communication module Beidou GPS module Beidou communication terminal DTU
JS变色的乐高积木
Redis exploration: cache breakdown, cache avalanche, cache penetration
Different test techniques
PG基础篇--逻辑结构管理(触发器)
Run PowerShell script prompt "because running script is prohibited on this system" solution
股票开户要认识谁?实际上网上开户安全么?
游戏公会在去中心化游戏中的未来
Report on the "14th five year plan" and scale prospect prediction of China's laser processing equipment manufacturing industry Ⓢ 2022 ~ 2028
Reasons for MySQL reporting 1040too many connections and Solutions
Report on the "14th five year plan" and investment strategy recommendations for China's industrial robot industry 2022 ~ 2028
简单的两个圆球loading加载
终端识别技术和管理技术
How to play with the reading and writing operations of blocking sockets?
Apache-Atlas-2.2.0 独立编译部署
Introduction to reverse debugging PE structure input table output table 05/07
机器学习—性能度量
一款Flutter版的记事本
R language builds a binary classification model based on H2O package: using H2O GBM build gradient hoist model GBM, use H2O AUC value of AUC calculation model
Professor Li Zexiang, Hong Kong University of science and technology: I'm wrong. Why is engineering consciousness more important than the best university?