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 561cacaff541e4ae204ef20337c0c2dcf8b25260..b202137133ce6baccdc69cd83b8f0988190e3d11 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 4ad647bd6f1fd89e6c1936bda988abf481621393..77fe4b9505db2586c36fda4918a113a2205b3c78 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 9a7ea33c25f4fabb460a2d0d3492c3df1223ff30..1088ae65ef19f1e1541276eec2d07249a4dc2666 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;