当前位置: 首页 > wzjs >正文

天元建设集团有限公司济南分公司网站推广专家十年乐云seo

天元建设集团有限公司济南分公司,网站推广专家十年乐云seo,西红门做网站,北京律师网站建设推荐一、需求场景 进入到app首页或者分页列表首页时,随着页面滚动,分类tab要求固定悬浮在顶部。进入到app首页、者分页列表首页、商品详情页时,页面滚动时,顶部导航栏(菜单、标题)背景渐变。 二、相关技术知识点…

一、需求场景

  • 进入到app首页或者分页列表首页时,随着页面滚动,分类tab要求固定悬浮在顶部。
  • 进入到app首页、者分页列表首页、商品详情页时,页面滚动时,顶部导航栏(菜单、标题)背景渐变。

二、相关技术知识点

  • Scroll:可滚动容器,其中nestedScroll:设置父组件的滚动联动、onDidScroll:滚动事件回调
  • Stack:堆叠容器

三、解决方案

  1. 使用Stack层叠布局,将标题栏悬浮展示在页面顶部。
  2. 考虑页面滚动以及tabContent里面的list滚动就要考虑滚动嵌套问题目前场景需要选择:
    向上滚动时,父组件先滚动,父组件滚动到边缘以后自身滚动;
    向下滚动时:自身先滚动,自身滚动到边缘以后父组件滚动。

四、示例

效果图

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

示例代码:TestStickyNestedScroll.ets

import AppStorageConstants from '../../common/AppStorageConstants';@Entry
@Component
struct TestStickyNestedScroll {@State arr: number[] = [];@State opacityNum: number = 0;@State curYOffset: number = 0;@State statusBarHeight: number = 20@State bottomNavBarHeight: number = 20@State navIndicatorHeight: number| undefined = 28aboutToAppear(): void {for (let index = 0; index < 40; index++) {this.arr.push(index);}let tempStatusBarHeight: number | undefined = AppStorage.get(AppStorageConstants.STATUS_BAR_HEIGHT)this.statusBarHeight = tempStatusBarHeight == undefined ? 20 : tempStatusBarHeightthis.navIndicatorHeight = AppStorage.get(AppStorageConstants.NAV_INDICATOR_HEIGHT)// let typeSys = window.AvoidAreaType.TYPE_SYSTEM;// let typeNavIndicator = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR;// window.getLastWindow(getContext(this)).then((data) => {//   // 获取系统默认区域,一般包括状态栏、导航栏//   let avoidArea1 = data.getWindowAvoidArea(typeSys);//   // 顶部状态栏高度//   let orginStatusBarHeight = avoidArea1.topRect.height;//////   this.statusBarHeight = this.getUIContext().px2vp(orginStatusBarHeight);//   console.log("顶部状态栏高度 statusBarHeight = " + this.statusBarHeight + " vp,  orginStatusBarHeight = " +//     orginStatusBarHeight + " px");//   // 部状态栏高度 statusBarHeight = 32.92307692307692 vp,  orginStatusBarHeight = 107 px////   // 底部导航条区域高度//   let avoidArea2 = data.getWindowAvoidArea(typeNavIndicator);//   let orginNavIndicator = avoidArea2.bottomRect.height//   this.navIndicatorHeight = this.getUIContext().px2vp(orginNavIndicator);//   console.log("底部导航条区域高度 navIndicatorHeight = " + this.navIndicatorHeight +//     " vp,  orginNavIndicator = " +//     orginNavIndicator + " px");//   // 底部导航条区域高度 navIndicatorHeight = 28 vp,  orginNavIndicator = 91 px////   //底部导航栏的高度//   let orginBottomStatusBarHeight = avoidArea1.bottomRect.height;//   this.bottomNavBarHeight = this.getUIContext().px2vp(orginBottomStatusBarHeight);//   console.log("底部导航栏的高度 statusBarHeight = " + this.bottomNavBarHeight + " vp,  orginBottomStatusBarHeight = " +//     orginBottomStatusBarHeight + " px");//   // 底部导航栏的高度 statusBarHeight = 0 vp,  orginBottomStatusBarHeight = 0 px// })}@StyleslistCard() {.backgroundColor(Color.White).height(72).width('calc(100% - 20vp)').borderRadius(12).margin({ left: 10, right: 10 })}build() {Stack() {Scroll() {Column({ space: 10 }) {Image($r('app.media.mount')).width('100%').height(300)Tabs({ barPosition: BarPosition.Start }) {TabContent() {List({ space: 10 }) {ForEach(this.arr, (item: number) => {ListItem() {Text("item " + item).fontSize(20).fontColor(Color.Black)}.listCard()}, (item: number) => item.toString())}.edgeEffect(EdgeEffect.Spring).nestedScroll({scrollForward: NestedScrollMode.PARENT_FIRST,scrollBackward: NestedScrollMode.SELF_FIRST})}.tabBar("待处理")TabContent() {}.tabBar("已处理")}.scrollable(false) // 禁掉滚动.vertical(false).width("100%").height('calc(100% - 60vp)')}.width('100%')}.edgeEffect(EdgeEffect.Spring).friction(0.6).backgroundColor('#DCDCDC').scrollBar(BarState.Off).width('100%').height('100%').onDidScroll((xOffset: number, yOffset: number, scrollState: ScrollState): void => {// 累计计算当前父组件滚动在Y轴方向的偏移量this.curYOffset += yOffset// 根据父组件一共可以滚动的距离计算当前每帧的当前透明度let opacity = this.curYOffset / 240if (opacity >= 1) {opacity = 1}if (opacity <= 0) {opacity = 0}this.opacityNum = opacity})RelativeContainer() { //顶部菜单栏Text("返回").fontSize(16).fontColor(Color.Black).fontWeight(FontWeight.Medium).padding({ left: 20 }).height('100%').alignRules({top: { anchor: '__container__', align: VerticalAlign.Top },left: { anchor: '__container__', align: HorizontalAlign.Start }}).id('back')Text("标题").fontSize(16).fontColor(Color.Black).fontWeight(FontWeight.Medium).textAlign(TextAlign.Center).alignRules({top: { anchor: '__container__', align: VerticalAlign.Top },bottom: { anchor: '__container__', align: VerticalAlign.Bottom },left: { anchor: 'back', align: HorizontalAlign.End },right: { anchor: 'share', align: HorizontalAlign.Start }})Text("分享").fontSize(16).fontColor(Color.Black).fontWeight(FontWeight.Medium).padding({ right: 20 }).height('100%').alignRules({top: { anchor: '__container__', align: VerticalAlign.Top },right: { anchor: '__container__', align: HorizontalAlign.End }}).id('share')}.width('100%').height(44 + this.statusBarHeight).padding({ top: this.statusBarHeight }).position({ x: 0, y: 0 }).backgroundColor(`rgba(255,255,255,${this.opacityNum})`)}.height('100%').width('100%')}
}
http://www.dtcms.com/wzjs/34072.html

相关文章:

  • 网站备案查询怎么查网络零售的优势有哪些
  • 网站html设置首页百度推广怎么操作流程
  • 上海企业网站定制整站优化服务
  • 做专题页的网站广州最近爆发什么病毒
  • 北京市朝阳区网站制作公司seo网站优化推广
  • 网站建设如何创业中国域名注册局官网
  • 类似朋友圈wordpress新网站排名优化怎么做
  • 网站建设费用评估品牌企业seo咨询
  • 专业网站建设费用报价seo网站排名优化快速排
  • 临沂建设局网站质量三监督seo优化排名服务
  • 盐城网站设计引流推广广告怎么写
  • wordpress 主机安装西安百度首页优化
  • 自己做国际网站淘宝关键词工具
  • 网站建设方案设计心得贵州seo技术培训
  • 大学生个人简历电子版模板苏州seo网站管理
  • 屯昌网站建设建设营销网站
  • 文化传媒网站php源码尚硅谷培训机构官网
  • 哪个网站可以直接做ppt官网seo关键词排名系统
  • 如何做网站霸屏网络宣传策划方案
  • 郑州网站建设公司电话多少沧州搜索引擎优化
  • 做图书网站的代码互联网品牌的快速推广
  • 岳阳博物馆网站跨境电商怎么做
  • 门户网站的注意要素产品推广软文范文
  • 本地做网站贵seo的中文意思
  • 如何做请求队列防止网站高并发网址信息查询
  • 网站制作与免费网站建设网络营销的十大特点
  • 做包装盒效果图的网站口碑营销ppt
  • 网站后台用什么浏览器软文推广范文
  • 威海网站网站建设深圳网络推广哪家好
  • 免费建站哪里找推广引流怎么做