Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
2dfde4b2
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
2dfde4b2
编写于
8月 31, 2023
作者:
W
wanganxp
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
去除废文件,新闻详情改为rich-text,临时去除影响复杂长列表左右滑动卡的写法
上级
bcfc6f4a
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
200 addition
and
565 deletion
+200
-565
App.uvue
App.uvue
+2
-5
components/uni-collapse-item/util.uts
components/uni-collapse-item/util.uts
+1
-1
pages.json
pages.json
+1
-7
pages/component/list-news/detail/detail.uvue
pages/component/list-news/detail/detail.uvue
+15
-46
pages/tabBar/template.uvue
pages/tabBar/template.uvue
+2
-2
pages/template/long-list/long-list-page.uvue
pages/template/long-list/long-list-page.uvue
+1
-1
pages/template/long-list/long-list.uvue
pages/template/long-list/long-list.uvue
+3
-2
pages/template/scroll-fold-nav/scroll-fold-header/scroll-fold-header.uvue
...croll-fold-nav/scroll-fold-header/scroll-fold-header.uvue
+0
-119
pages/template/scroll-fold-nav/scroll-fold-nav.uvue
pages/template/scroll-fold-nav/scroll-fold-nav.uvue
+175
-75
pages/template/scroll-fold-nav2/scroll-fold-nav2.uvue
pages/template/scroll-fold-nav2/scroll-fold-nav2.uvue
+0
-193
pages/template/scroll-sticky2/scroll-sticky2.uvue
pages/template/scroll-sticky2/scroll-sticky2.uvue
+0
-114
未找到文件。
App.uvue
浏览文件 @
2dfde4b2
...
@@ -11,10 +11,7 @@ export default {
...
@@ -11,10 +11,7 @@ export default {
const performance = uni.getPerformance()
const performance = uni.getPerformance()
const observer1: PerformanceObserver = performance.createObserver(
const observer1: PerformanceObserver = performance.createObserver(
(entryList: PerformanceObserverEntryList) => {
(entryList: PerformanceObserverEntryList) => {
console.log(
console.log('observer1:entryList.getEntries()' +JSON.stringify(entryList.getEntries()))
'observer1:entryList.getEntries()' +
JSON.stringify(entryList.getEntries())
)
}
}
)
)
observer1.observe({
observer1.observe({
...
@@ -46,7 +43,7 @@ export default {
...
@@ -46,7 +43,7 @@ export default {
}, 2000)
}, 2000)
} else if (Date.now() - firstBackTime < 2000) {
} else if (Date.now() - firstBackTime < 2000) {
firstBackTime = Date.now()
firstBackTime = Date.now()
uni.exit(
null
)
uni.exit()
}
}
},
},
onExit(){
onExit(){
...
...
components/uni-collapse-item/util.uts
浏览文件 @
2dfde4b2
...
@@ -12,7 +12,7 @@ export function $dispatch(
...
@@ -12,7 +12,7 @@ export function $dispatch(
while (parent != null && (name == null || componentName != name)) {
while (parent != null && (name == null || componentName != name)) {
parent = parent.$parent
parent = parent.$parent
if (parent != null) {
if (parent != null) {
name = parent
?
.$options?.name
name = parent.$options?.name
}
}
}
}
if (parent != null) {
if (parent != null) {
...
...
pages.json
浏览文件 @
2dfde4b2
...
@@ -762,12 +762,6 @@
...
@@ -762,12 +762,6 @@
"navigationBarTitleText"
:
"滚动吸顶"
"navigationBarTitleText"
:
"滚动吸顶"
}
}
},
},
{
"path"
:
"pages/template/scroll-sticky2/scroll-sticky2"
,
"style"
:
{
"navigationBarTitleText"
:
"滚动吸顶2"
}
},
{
{
"path"
:
"pages/API/get-battery-info/get-battery-info"
,
"path"
:
"pages/API/get-battery-info/get-battery-info"
,
"style"
:
{
"style"
:
{
...
@@ -781,7 +775,7 @@
...
@@ -781,7 +775,7 @@
}
}
},
},
{
{
"path"
:
"pages/template/scroll-fold-nav
2/scroll-fold-nav2
"
,
"path"
:
"pages/template/scroll-fold-nav
/scroll-fold-nav
"
,
"style"
:
{
"style"
:
{
"navigationStyle"
:
"custom"
,
"navigationStyle"
:
"custom"
,
"navigationBarTextStyle"
:
"black"
"navigationBarTextStyle"
:
"black"
...
...
pages/component/list-news/detail/detail.uvue
浏览文件 @
2dfde4b2
<template>
<template>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<scroll-view style="flex: 1">
<!-- #endif -->
<!-- #endif -->
<view>
<view class="banner">
<view class="banner">
<image class="banner-img" :src="cover"></image>
<image class="banner-img" :src="cover"></image>
<text class="banner-title">{{title}}</text>
<text class="banner-title">{{title}}</text>
</view>
</view>
<rich-text :nodes="htmlNodes" style="padding: 3px"></rich-text>
<view class="article-content">
<!-- #ifdef APP -->
<text>{{htmlNodes}}</text>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
<!-- #endif -->
<!-- #endif -->
</template>
</template>
...
@@ -21,33 +17,28 @@
...
@@ -21,33 +17,28 @@
data() {
data() {
return {
return {
htmlNodes: "",
htmlNodes: "",
pageVisible: false,
title: '',
title: '',
cover: "",
cover: "",
post_id: "",
post_id: "",
}
}
},
},
onLoad(event) {
onLoad(event) {
this.pageVisible = true
;
// console.log(event)
;
this.post_id = event["post_id"] ?? "";
this.post_id = event["post_id"] ?? "";
this.cover = event["cover"] ?? "";
this.cover = event["cover"] ?? "";
this.title = event["title"] ?? "";
this.title = event["title"] ?? "";
this.getDetail();
this.getDetail();
},
},
onUnload() {
this.pageVisible = false;
},
methods: {
methods: {
getDetail() {
getDetail() {
uni.request({
uni.request({
url: 'https://unidemo.dcloud.net.cn/api/news/36kr/' + this.post_id,
url: 'https://unidemo.dcloud.net.cn/api/news/36kr/' + this.post_id,
success: (data) => {
success: (data) => {
if (this.pageVisible) {
if (data.statusCode == 200) {
if (data.statusCode == 200) {
const result = data.data as UTSJSONObject
const result = data.data as UTSJSONObject
// console.log(result["content"]);
this.htmlNodes = result["content"] as string;
this.htmlNodes = result["content"] as string;
}
}
}
},
},
fail: () => {
fail: () => {
console.log('fail');
console.log('fail');
...
@@ -81,32 +72,10 @@
...
@@ -81,32 +72,10 @@
font-weight: 400;
font-weight: 400;
line-height: 42rpx;
line-height: 42rpx;
color: white;
color: white;
/* z-index: 11; */
}
.article-meta {
padding: 20rpx 40rpx;
display: flex;
flex-direction: row;
justify-content: flex-start;
color: gray;
}
}
.article-text {
font-size: 26rpx;
line-height: 50rpx;
margin: 0 20rpx;
}
.article-author,
.article-time {
font-size: 30rpx;
}
.article-content {
.article-content {
padding: 0 30rpx;
padding: 0 30rpx;
overflow: hidden;
overflow: hidden;
font-size: 30rpx;
margin-bottom: 30rpx;
margin-bottom: 30rpx;
}
}
</style>
</style>
\ No newline at end of file
pages/tabBar/template.uvue
浏览文件 @
2dfde4b2
...
@@ -89,8 +89,8 @@ export default {
...
@@ -89,8 +89,8 @@ export default {
pages: [] as Page[],
pages: [] as Page[],
},
},
{
{
id: 'scroll-fold-nav
2
',
id: 'scroll-fold-nav',
url: 'scroll-fold-nav
2
',
url: 'scroll-fold-nav',
name: '随滚动折叠的导航栏',
name: '随滚动折叠的导航栏',
open: false,
open: false,
pages: [] as Page[],
pages: [] as Page[],
...
...
pages/template/long-list/long-list-page.uvue
浏览文件 @
2dfde4b2
...
@@ -134,7 +134,7 @@
...
@@ -134,7 +134,7 @@
})
})
},
},
// score 0 ~ 50
// score 0 ~ 50
convertToStarUnicode(score :
N
umber) : string {
convertToStarUnicode(score :
n
umber) : string {
const fill_code = '\ue879'
const fill_code = '\ue879'
const half_code = '\ue87a'
const half_code = '\ue87a'
const null_code = '\ue87b'
const null_code = '\ue87b'
...
...
pages/template/long-list/long-list.uvue
浏览文件 @
2dfde4b2
...
@@ -120,7 +120,8 @@
...
@@ -120,7 +120,8 @@
const indicator_line_w = current_size.w + (move_to_size.w - current_size.w) * percentage
const indicator_line_w = current_size.w + (move_to_size.w - current_size.w) * percentage
// 更新蛇形线位置和大小
// 更新蛇形线位置和大小
this.updateTabIndicator(indicator_line_l, indicator_line_w)
// 这代码写的不对,不能在拖动滚动中使用vue绑定样式,只能用ref+transform
// this.updateTabIndicator(indicator_line_l, indicator_line_w)
// 首次可见时初始化数据
// 首次可见时初始化数据
this.initSwiperItemPage(move_to_index)
this.initSwiperItemPage(move_to_index)
...
@@ -218,4 +219,4 @@
...
@@ -218,4 +219,4 @@
.swiper-item {
.swiper-item {
flex: 1;
flex: 1;
}
}
</style>
</style>
\ No newline at end of file
pages/template/scroll-fold-nav/scroll-fold-header/scroll-fold-header.uvue
已删除
100644 → 0
浏览文件 @
bcfc6f4a
<template>
<view class="top-box" :style="headBoxStyle">
<view class="scroll-fold-nav" :style="titleStyle">
<view class="nav-title">DCloud 为开发者而生</view>
</view>
<view @click="back" class="nav-back">
<image class="back-img" src="/static/template/scroll-fold-nav/back.png" mode="widthFix"></image>
</view>
<view class="search" @click="toSearchPage" :style="{
'width':maxSearchWidth - (scrollTop>40?40:scrollTop) +'rpx',
'top':0 - (scrollTop>40?40:scrollTop) +'px'
}">
<view class="search-inner">
<image class="search-img" src="/static/template/scroll-fold-nav/search.png" mode="widthFix"></image>
<text class="search-tip-text">请输入你要搜索的内容</text>
</view>
<text class="search-btn">搜索</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
scrollTop: 0,
maxSearchWidth: 700
}
},
computed: {
// 修理导航栏头部高度和背景颜色变化
headBoxStyle() : string {
const scrollTop = this.scrollTop
let style = `height: ${110 - (scrollTop > 40 ? 40 : scrollTop)}px;background-color: rgba(255, 255, 255, ${(scrollTop * 3 > 100 ? 100 : scrollTop * 3) / 100})`
return style
},
// 处理导航栏标题透明度变化
titleStyle() : string {
const scrollTop = this.scrollTop
let style = `opacity: ${1 - (scrollTop * 3 > 100 ? 100 : scrollTop * 3) / 100}`
return style
}
},
methods: {
toSearchPage() {
this.$emit('toSearchPage')
},
back() {
this.$emit('back')
}
}
}
</script>
<style>
.top-box {
position: fixed;
top: 0;
padding-top: 25px;
align-items: flex-end;
border-bottom: 1px solid #efefef;
}
.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;
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;
}
</style>
\ No newline at end of file
pages/template/scroll-fold-nav/scroll-fold-nav.uvue
浏览文件 @
2dfde4b2
<template>
<template>
<view class="page">
<view class="page">
<scroll-view :scroll-y="true" @scroll="onScroll" class="scroll-view">
<scroll-view :scroll-y="true" @scroll="onScroll" class="scroll-view" rebound="false">
<view class="height-seat"
>
<view class="height-seat"
style="height: 110px;">
<!-- 垫高专用 -->
<!-- 垫高专用 -->
</view>
</view>
<view class="content">
<view class="content">
<view class="content-item">
<view class="content-item">
<text class="text">1. 当前示例监听了 scroll-view 的 scroll 事件 ,滚动页面实时监听
scrollTop。</text>
<text class="text">1. 当前示例监听了 scroll-view 的 scroll 事件 ,滚动页面实时监听scrollTop。</text>
<text class="text">2.
在模板中根据 scrollTop 的变化,通过 style 修改搜索导航栏的高度、位置和背景颜色等样式,从而达到滚动折叠的效果。</text>
<text class="text">2.
使用 ref 直接获取元素的节点,并在 scroll 事件中通过节点的 setProperty 方法来修改搜索导航栏的高度、位置和背景颜色等样式,从而达到滚动折叠的效果。</text>
<text class="text">3. 请向上\向下滚动页面观察效果。</text>
<text class="text">3. 请向上\向下滚动页面观察效果。</text>
</view>
</view>
<view class="content-item" v-for="(item,index) in 20" :key="index">
<view class="content-item" v-for="(item,index) in 20" :key="index">
<text class="text">content-{{item}}</text>
<text class="text">content-{{item}}</text>
</view>
</view>
</view>
</view>
</scroll-view>
</scroll-view>
<scroll-fold-header ref="header" @back="back" @toSearchPage="toSearchPage()" />
</view>
<view ref="top-box" class="top-box">
<view ref="scroll-fold-nav" class="scroll-fold-nav">
<view class="nav-title">DCloud 为开发者而生</view>
</view>
<view @click="back" class="nav-back">
<image class="back-img" src="/static/template/scroll-fold-nav/back.png" mode="widthFix"></image>
</view>
<view ref="search" class="search" @click="toSearchPage">
<view class="search-inner">
<image class="search-img" src="/static/template/scroll-fold-nav/search.png" mode="widthFix"></image>
<text class="search-tip-text">请输入你要搜索的内容</text>
</view>
<text class="search-btn">搜索</text>
</view>
</view>
</view>
</template>
</template>
<script>
<script>
import scrollFoldHeader from './scroll-fold-header/scroll-fold-header.uvue';
export default {
export default {
data() {
components: { scrollFoldHeader },
return {
data() {
scrollTop: 0,
return {}
searchWidth: 700,
searchNode: null as INode | null,
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: {
methods: {
onScroll(e : ScrollEvent) {
onScroll(e : ScrollEvent) {
(this.$refs['header'] as ComponentPublicInstance).$data['scrollTop'] = (e.detail.scrollTop < 0 ? 0 : e.detail.scrollTop)
let scrollTop = e.detail.scrollTop
},
this.boxNode?.style?.setProperty('height', (110 - (scrollTop > 40 ? 40 : scrollTop)) + 'px');
back() {
this.boxNode?.style?.setProperty('backgroundColor', 'rgba(255, 255, 255, ' + (scrollTop * 3 > 100 ? 100 : scrollTop * 3) / 100.0 + ')');
// uni.navigateBack() // 这么写用不了
this.navNode?.style?.setProperty('opacity', 1 - (scrollTop * 3 > 100 ? 100 : scrollTop * 3) / 100.0);
// 这么写可以用
this.searchNode?.style?.setProperty('width', 700 - (scrollTop > 40 ? 40 : scrollTop) + 'rpx');
uni.navigateBack({
this.searchNode?.style?.setProperty('top', 0 - (scrollTop > 40 ? 40 : scrollTop) + 'px');
success(result) {
this.scrollTop = scrollTop;
console.log('navigateBack success', result.errMsg)
},
},
back() {
fail(error) {
// uni.navigateBack() // 这么写用不了
console.log('navigateBack fail', error.errMsg)
// 这么写可以用
},
uni.navigateBack({
complete(result) {
success(result) {
console.log('navigateBack complete', result.errMsg)
console.log('navigateBack success', result.errMsg)
},
},
})
fail(error) {
},
console.log('navigateBack fail', error.errMsg)
toSearchPage() {
},
uni.showToast({
complete(result) {
title: '暂不支持',
console.log('navigateBack complete', result.errMsg)
icon: 'none'
},
});
})
}
},
// uni.switchTab({
onLoad() { }
// url:'/pages/tabBar/template'
}
// })
},
toSearchPage() {
uni.showToast({
title: '暂不支持',
icon: 'none'
});
}
},
}
</script>
</script>
<style>
<style>
.page {
.page {
flex: 1;
flex: 1;
background-color: #fbdf0d;
background-color: #fbdf0d;
/* background-color: #f5f5f5; */
}
}
.scroll-view {
.scroll-view {
flex: 1;
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;
}
}
.height-seat {
.top-box {
height: 110px;
position: fixed;
/* background-color: #fbdf0d; */
top: 0;
}
padding-top: 25px;
align-items: flex-end;
border-bottom: 1px solid #efefef;
height:110px;
background-color:rgba(255,255,255,0)
}
.content {
.scroll-fold-nav {
padding: 5px 15px;
height: 44px;
background-color: #f5f5f5;
width: 750rpx;
justify-content: center;
}
.nav-title {
margin-left: 30px;
}
}
.content-item {
.nav-back {
padding: 15px;
position: absolute;
margin: 5px 0;
top: 35px;
background-color: #fff;
left: 8px;
border-radius: 5px;
}
.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;
width:700rpx;
top:0px
}
.search-inner {
margin-top: 2px;
flex-direction: row;
}
.search-inner .search-img {
width: 15px;
}
}
.text {
.search-tip-text {
font-size: 14px;
font-size: 12px;
color: #666;
color: #666;
line-height: 20px;
}
}
.search-btn {
font-size: 12px;
background-color: #ff6900;
color: #FFF;
padding: 5px 8px;
border-radius: 100px;
}
</style>
</style>
\ No newline at end of file
pages/template/scroll-fold-nav2/scroll-fold-nav2.uvue
已删除
100644 → 0
浏览文件 @
bcfc6f4a
<template>
<view class="page">
<scroll-view :scroll-y="true" @scroll="onScroll" class="scroll-view" rebound="false">
<view class="height-seat" style="height: 110px;">
<!-- 垫高专用 -->
</view>
<view class="content">
<view class="content-item">
<text class="text">1. 当前示例监听了 scroll-view 的 scroll 事件 ,滚动页面实时监听scrollTop。</text>
<text class="text">2. 使用 ref 直接获取元素的节点,并在 scroll 事件中通过节点的 setProperty 方法来修改搜索导航栏的高度、位置和背景颜色等样式,从而达到滚动折叠的效果。</text>
<text class="text">3. 请向上\向下滚动页面观察效果。</text>
</view>
<view class="content-item" v-for="(item,index) in 20" :key="index">
<text class="text">content-{{item}}</text>
</view>
</view>
</scroll-view>
<view ref="top-box" class="top-box">
<view ref="scroll-fold-nav" class="scroll-fold-nav">
<view class="nav-title">DCloud 为开发者而生</view>
</view>
<view @click="back" class="nav-back">
<image class="back-img" src="/static/template/scroll-fold-nav/back.png" mode="widthFix"></image>
</view>
<view ref="search" class="search" @click="toSearchPage">
<view class="search-inner">
<image class="search-img" src="/static/template/scroll-fold-nav/search.png" mode="widthFix"></image>
<text class="search-tip-text">请输入你要搜索的内容</text>
</view>
<text class="search-btn">搜索</text>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
scrollTop: 0,
searchWidth: 700,
searchNode: null as INode | null,
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
this.boxNode?.style?.setProperty('height', (110 - (scrollTop > 40 ? 40 : scrollTop)) + 'px');
this.boxNode?.style?.setProperty('backgroundColor', 'rgba(255, 255, 255, ' + (scrollTop * 3 > 100 ? 100 : scrollTop * 3) / 100.0 + ')');
this.navNode?.style?.setProperty('opacity', 1 - (scrollTop * 3 > 100 ? 100 : scrollTop * 3) / 100.0);
this.searchNode?.style?.setProperty('width', 700 - (scrollTop > 40 ? 40 : scrollTop) + 'rpx');
this.searchNode?.style?.setProperty('top', 0 - (scrollTop > 40 ? 40 : scrollTop) + 'px');
this.scrollTop = scrollTop;
},
back() {
// uni.navigateBack() // 这么写用不了
// 这么写可以用
uni.navigateBack({
success(result) {
console.log('navigateBack success', result.errMsg)
},
fail(error) {
console.log('navigateBack fail', error.errMsg)
},
complete(result) {
console.log('navigateBack complete', result.errMsg)
},
})
// uni.switchTab({
// url:'/pages/tabBar/template'
// })
},
toSearchPage() {
uni.showToast({
title: '暂不支持',
icon: 'none'
});
}
},
}
</script>
<style>
.page {
flex: 1;
background-color: #fbdf0d;
}
.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;
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;
height: 35px;
border-radius: 100px;
margin: 0 25rpx;
padding: 8px;
flex-direction: row;
align-items: center;
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;
color: #666;
}
.search-btn {
font-size: 12px;
background-color: #ff6900;
color: #FFF;
padding: 5px 8px;
border-radius: 100px;
}
</style>
\ No newline at end of file
pages/template/scroll-sticky2/scroll-sticky2.uvue
已删除
100644 → 0
浏览文件 @
bcfc6f4a
<template>
<scroll-view :scroll-y="true" @scroll="onScroll" class="page">
<view v-for="(item,index) in list" :key="index" class="item">
first content-{{item}}
</view>
<view ref="sticky" class="search" @click="" :style="{
'transform': 'translateY('+stickyTran+'px)'
}">
<!-- <view ref="sticky" class="search" @click=""> -->
<view style="flex-direction: row;">
<image src="/static/template/scroll-fold-nav/search.png" style="width: 15px;" mode="widthFix"></image>
<text class="search-tip-text">请输入你要搜索的内容</text>
</view>
<text class="search-btn">搜索</text>
</view>
<view v-for="(item,index) in list" :key="index" class="item">
second content-{{item}}
</view>
<view v-for="(item,index) in list" :key="index" class="item">
second content-{{item}}
</view>
</scroll-view>
</template>
<script>
export default {
data() {
return {
list: ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15'],
stickyTop: 0,
stickyTran: 0,
scrollTop: 0,
stickyNode: null as INode | null
}
},
methods: {
onScroll(e : ScrollEvent) {
if(e.detail.scrollTop > this.stickyTop){
let stickyTran = e.detail.scrollTop - this.stickyTop;
// this.stickyNode?.style?.setProperty('transform','translateY('+stickyTran+'px)');
this.stickyTran = stickyTran;
}else{
// this.stickyNode?.style?.setProperty('transform','');
this.stickyTran = 0;
}
},
back(){
uni.navigateBack({
success(result) {
console.log('navigateBack success', result.errMsg)
},
fail(error) {
console.log('navigateBack fail', error.errMsg)
},
complete(result) {
console.log('navigateBack complete', result.errMsg)
},
})
}
},
onLoad() {
},
onReady() {
this.stickyNode = this.$refs['sticky'] as INode;
// let rect = this.stickyNode?.getBoundingClientRect();
// this.stickyTop = rect?.top;
let rect = (this.$refs['sticky'] as INode).getBoundingClientRect();
this.stickyTop = rect.top;
}
}
</script>
<style>
.page {
flex: 1;
background-color: azure;
}
.item {
height: 100px;
}
.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-tip-text {
font-size: 12px;
color: #666;
}
.search-btn {
font-size: 12px;
background-color: #ff6900;
color: #FFF;
padding: 5px 8px;
border-radius: 100px;
}
</style>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录