From f5e2d9b00f63ceef276e43b398333063e4b3a6cd Mon Sep 17 00:00:00 2001
From: mehaotian <490272692@qq.com>
Date: Wed, 16 Aug 2023 16:13:43 +0800
Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=BB=9A=E5=8A=A8?=
=?UTF-8?q?=E6=8A=98=E5=8F=A0=E7=A4=BA=E4=BE=8B=E7=9A=84=E6=A0=B7=E5=BC=8F?=
=?UTF-8?q?=EF=BC=8C=E8=B0=83=E6=95=B4=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E7=BB=93=E6=9E=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../scroll-fold-header.uvue | 193 +++++++++++-------
.../scroll-fold-nav/scroll-fold-nav.uvue | 140 ++++++++-----
.../scroll-fold-nav2/scroll-fold-nav2.uvue | 110 +++++++---
3 files changed, 282 insertions(+), 161 deletions(-)
diff --git a/pages/template/scroll-fold-nav/scroll-fold-header/scroll-fold-header.uvue b/pages/template/scroll-fold-nav/scroll-fold-header/scroll-fold-header.uvue
index 561cacaf..b2021371 100644
--- a/pages/template/scroll-fold-nav/scroll-fold-header/scroll-fold-header.uvue
+++ b/pages/template/scroll-fold-nav/scroll-fold-header/scroll-fold-header.uvue
@@ -1,82 +1,119 @@
-
-
-
- DCloud 为开发者而生
-
-
-
-
-
-
-
- 请输入你要搜索的内容
-
- 搜索
-
-
-
-
-
-
-
+ .nav-title {
+ margin-left: 30px;
+ }
+
+ .nav-back {
+ position: absolute;
+ top: 35px;
+ left: 8px;
+ }
+
+ .nav-back .back-img {
+ width: 18px;
+ margin-top: 2px;
+ }
+
+ .search {
+ background-color: #FFFFFF;
+ border: 1px solid #fbdf0d;
+ height: 35px;
+ border-radius: 100px;
+ margin: 0 25rpx;
+ padding: 8px;
+ flex-direction: row;
+ align-items: center;
+ justify-content: space-between;
+ }
+
+ .search-inner {
+ margin-top: 2px;
+ flex-direction: row;
+ }
+
+ .search-inner .search-img {
+ width: 15px;
+ }
+
+ .search-tip-text {
+ font-size: 12px;
+ color: #666;
+ }
+
+ .search-btn {
+ font-size: 12px;
+ background-color: #ff6900;
+ color: #FFF;
+ padding: 5px 8px;
+ border-radius: 100px;
+ }
+
\ No newline at end of file
diff --git a/pages/template/scroll-fold-nav/scroll-fold-nav.uvue b/pages/template/scroll-fold-nav/scroll-fold-nav.uvue
index 4ad647bd..77fe4b95 100644
--- a/pages/template/scroll-fold-nav/scroll-fold-nav.uvue
+++ b/pages/template/scroll-fold-nav/scroll-fold-nav.uvue
@@ -1,64 +1,94 @@
-
-
-
-
-
-
-
- content-{{item}}
-
-
-
-
-
+
+
+
+
+
+
+
+ 1. 当前示例监听了 scroll-view 的 scroll 事件 ,滚动页面实时监听 scrollTop。
+ 2. 在模板中根据 scrollTop 的变化,通过 style 修改搜索导航栏的高度、位置和背景颜色等样式,从而达到滚动折叠的效果。
+ 3. 请向上\向下滚动页面观察效果。
+
+
+ content-{{item}}
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/template/scroll-fold-nav2/scroll-fold-nav2.uvue b/pages/template/scroll-fold-nav2/scroll-fold-nav2.uvue
index 9a7ea33c..1088ae65 100644
--- a/pages/template/scroll-fold-nav2/scroll-fold-nav2.uvue
+++ b/pages/template/scroll-fold-nav2/scroll-fold-nav2.uvue
@@ -1,26 +1,31 @@
-
-
-
-
-
-
- content-{{item}}
+
+
+
+
+
+
+ 1. 当前示例监听了 scroll-view 的 scroll 事件 ,滚动页面实时监听scrollTop。
+ 2. 与上一个示例不同的是,此示例使用 ref 直接获取了元素的节点,并在 scroll 事件中通过节点的 setProperty 方法来修改搜索导航栏的高度、位置和背景颜色等样式,从而达到滚动折叠的效果。
+ 3. 请向上\向下滚动页面观察效果。
+
+
+ content-{{item}}
-
+
- DCloud 为开发者而生
+ DCloud 为开发者而生
-
-
+
+
-
-
-
+
+
+
请输入你要搜索的内容
搜索
@@ -41,7 +46,13 @@
boxNode: null as INode | null,
navNode: null as INode | null
}
- },
+ },
+ onLoad() {},
+ onReady() {
+ this.searchNode = this.$refs['search'] as INode;
+ this.boxNode = this.$refs['top-box'] as INode;
+ this.navNode = this.$refs['scroll-fold-nav'] as INode;
+ },
methods: {
onScroll(e : ScrollEvent) {
let scrollTop = e.detail.scrollTop
@@ -79,13 +90,7 @@
});
}
},
- onLoad() {
- },
- onReady() {
- this.searchNode = this.$refs['search'] as INode;
- this.boxNode = this.$refs['top-box'] as INode;
- this.navNode = this.$refs['scroll-fold-nav'] as INode;
- }
+
}
@@ -97,22 +102,60 @@
.scroll-view {
flex: 1;
- }
+ }
+
+ .height-seat {
+ height: 110px;
+ /* background-color: #fbdf0d; */
+ }
+ .content {
+ padding: 5px 15px;
+ background-color: #f5f5f5;
+ }
+ .content-item {
+ padding: 15px;
+ margin: 5px 0;
+ background-color: #fff;
+ border-radius: 5px;
+
+ }
+ .text {
+ font-size: 14px;
+ color: #666;
+ line-height: 20px;
+ }
.top-box {
position: fixed;
top: 0;
padding-top: 25px;
align-items: flex-end;
- border-bottom: 1px solid #efefef;
+ border-bottom: 1px solid #efefef;
+ height:110px;
+ background-color:rgba(255,255,255,0)
}
.scroll-fold-nav {
height: 44px;
width: 750rpx;
justify-content: center;
- }
-
+ }
+
+ .nav-title {
+ margin-left: 30px;
+ }
+
+ .nav-back {
+ position: absolute;
+ top: 35px;
+ left: 8px;
+ }
+
+ .nav-back .back-img {
+ width: 18px;
+ margin-top: 2px;
+ }
+
.search {
background-color: #FFFFFF;
border: 1px solid #fbdf0d;
@@ -122,8 +165,19 @@
padding: 8px;
flex-direction: row;
align-items: center;
- justify-content: space-between;
- }
+ justify-content: space-between;
+ width:700rpx;
+ top:0px
+ }
+
+ .search-inner {
+ margin-top: 2px;
+ flex-direction: row;
+ }
+
+ .search-inner .search-img {
+ width: 15px;
+ }
.search-tip-text {
font-size: 12px;
--
GitLab