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

b2c电子商务模式指的是最新黑帽seo教程

b2c电子商务模式指的是,最新黑帽seo教程,福建省人民政府公文格式细则,织梦模板自适应鸿蒙UI开发 本文旨在分享一些鸿蒙UI布局开发上的一些建议,特别是对屏幕宽高比发生变化时的应对思路和好的实践。 折叠屏适配 一般情况(自适应布局/响应式布局) 1.自适应布局 1.1自适应拉伸 左右组件定宽 TypeScript //左右定宽 Row() { …

鸿蒙UI开发

本文旨在分享一些鸿蒙UI布局开发上的一些建议,特别是对屏幕宽高比发生变化时的应对思路和好的实践。

折叠屏适配

一般情况(自适应布局/响应式布局

1.自适应布局

1.1自适应拉伸

左右组件定宽

TypeScript
//左右定宽
Row() {
  Text("健康使用手机")
    .fontSize(16)
    .width(135)
  Blank()
  Toggle({ type: ToggleType.Switch })
    .width(36)
}
.borderRadius(12)
.padding({ left: 13, right: 13 })
.backgroundColor('#FFFFFF')
.width('100%')

左右组件不定宽(左组件占剩余宽度,右组件不定宽)

TypeScript
//layoutWeight
//左右不定宽,
  Row() {
    ...
    Text("我的宽度占剩余的宽度"+"111111111111")
      .maxLines(1)
      .textOverflow({ overflow: TextOverflow.Ellipsis })
    ...
  }
  .layoutWeight(1)

  Text("我的宽度不固定")
    .textAlign(TextAlign.End)
    //这个margin自我调整,一般为做组件所有icon的宽度和
    .margin({ left: 54 })
}
.width('100%')

1.2均分拉伸

灵活使用弹性布局Flex

TypeScript
//不换行
Flex({ justifyContent: FlexAlign.SpaceEvenly }) {
  ForEach(this.list, () => {
    this.Item()
  })
}

//换行
Flex({ justifyContent: FlexAlign.Center ,wrap:FlexWrap.Wrap}) {
  ForEach(this.list, () => {
    this.Item()
  })
}

1.3自适应延伸

TypeScript
Scroll() {
  Row({ space: 10 }) {
    ForEach(this.appList, () => {
      Column() {
        Image($r('app.media.icon'))
          .width(48)
          .height(48)
        Text($r('app.string.show_app_name'))
          .fontSize(12)
          .textAlign(TextAlign.Center)
      }.width(80).height(102)
    })
  }
}
.scrollable(ScrollDirection.Horizontal)
.width("100%")

2.响应式布局

2.1媒体查询

TypeScript
//核心代码
private breakpoints: BreakpointEntity[] = [
  { name: 'xs', size: 0 }, { name: 'sm', size: 320 },
  { name: 'md', size: 600 }, { name: 'lg', size: 840 }
]

/**
 *
更新当前断点
 * 当传入的断点与当前断点不同时,更新当前断点并持久化
 */
private updateCurrentBreakpoint(breakpoint: string) {
  if (this.currentBreakpoint !== breakpoint) {
    this.currentBreakpoint = breakpoint;
    AppStorage.Set<string>('currentBreakpoint', this.currentBreakpoint);
    console.log('on current breakpoint: ' + this.currentBreakpoint);
  }
}

/**
 *
注册断点监听器
 * 为每个断点创建媒体查询监听器,当屏幕尺寸匹配时,更新当前断点
 */
public register() {
  this.breakpoints.forEach((breakpoint: BreakpointEntity, index) => {
    let condition :string = '';
    //
监听句柄,反应视窗宽度和breakpoint.size的关系
    if (index === this.breakpoints.length - 1) {
      condition = '(' + breakpoint.size + 'vp<=width' + ')';
    } else {
      condition = '(' + breakpoint.size + 'vp<=width<' + this.breakpoints[index + 1].size + 'vp)';
    }
    console.log(condition);
    // breakpoint.size vp <= width
的条件改变时触发回调,传递此时视窗大小
    breakpoint.mediaQueryListener = mediaQuery.matchMediaSync(condition);
    breakpoint.mediaQueryListener.on('change', (mediaQueryResult) => {
      if (mediaQueryResult.matches) {
        this.updateCurrentBreakpoint(breakpoint.name);
      }
    })
  })
}

3.典型布局场景

3.1挪移布局

 

栅格布局GridRow

TypeScript
GridRow() {
  GridCol({ span: { sm: 12, md: 6, lg: 6 } }) {
    Text("图片内容")
  }
  .width("100%")
  .height("50%")
  .backgroundColor(Color.Red)
  GridCol({ span: { sm: 12, md: 6, lg: 6 } }) {
      Text("文字标题")
  }
  .width("100%")
  .height("50%")
  .backgroundColor(Color.Blue)
}

3.2重复布局

栅格布局GridRow

TypeScript
Scroll() {
  GridRow() {
    ForEach([0, 1, 2, 3, 4, 5, 6, 7], () => {
      GridCol({ span: { sm: 12, md: 6, lg: 6 } }) {
        Column() {
          RepeatItemContent()
        }
      }
    })
  }
}

3.3顶部布局

栅格布局GridRow

TypeScript
@State needWrap: boolean = true

build() {
  GridRow() {
    // 第一行布局
    GridCol({ span: { sm: 12, md: 6, lg: 7 } }) {
      Row() {
        Text($r('app.string.recommended')).fontSize(24)
        Blank()
        Image($r('app.media.ic_public_more'))
          .width(32)
          .height(32)
          .visibility(this.needWrap ? Visibility.Visible : Visibility.None)
      }
      .width('100%')
      .alignItems(VerticalAlign.Center)
    }
    // 第二行布局
    GridCol({ span: { sm: 12, md: 6, lg: 5 } }) {
      Flex({ alignItems: ItemAlign.Center }) {
        Search({ placeholder: '猜您喜欢: 万水千山' })
        Image($r('app.media.audio_fm'))
          .width(32)
          .height(32)
        Image($r('app.media.ic_public_more'))
          .width(32)
          .height(32)
          .visibility(this.needWrap ? Visibility.None : Visibility.Visible)
      }
    }//控制显隐多余元素
  }.onBreakpointChange((breakpoint: string) => {
    if (breakpoint === 'sm') {
      this.needWrap = true
    } else {
      this.needWrap = false
    }
  })
}

3.复杂情况(判断手机的状态)

3.1折叠屏适配

TypeScript
// 当前折叠屏状态(若当前为折叠屏设备才有效)
@State curFoldStatus: display.FoldStatus = display.getFoldStatus();
if (display.isFoldable()) {
  // 监听折叠屏状态变更,更新折叠态
  display.on('foldStatusChange', (curFoldStatus: display.FoldStatus) => {
    this.curFoldStatus = curFoldStatus;
  })
}

build() {
   // 折叠屏UI展示
   if (display.isFoldable()) {
       ...
     }
   } else { // 非折叠屏UI展示
       ...
     }
   }
}

http://www.dtcms.com/wzjs/399449.html

相关文章:

  • 做儿童交互网站网络营销课程感悟
  • 做招聘网站怎么办营业执照怎么申请网站详细步骤
  • 化妆品企业网站建设的策划方案刷网站关键词工具
  • 邢台高端网站建设百度小说搜索风云榜总榜
  • 长寿做网站线上推广宣传方式有哪些
  • 莱钢建设网站乐云seo
  • 霸州做阿里巴巴网站绍兴网站快速排名优化
  • 那有名网站是php做的搜索引擎网站提交入口
  • wordpress 插入word优化网络的软件
  • 专门做h网页游戏的网站优化营商环境发言材料
  • 上海疫情为何不追责seo营销培训咨询
  • 江门加盟网站建设媒体软文发稿
  • 产品设计网站制作中国万网域名查询
  • 网站建设商务代表故事上海今日头条新闻
  • wordpress加载jquery库百度快速seo
  • 做网站在哪里买空间域名中文搜索引擎网站
  • 成都网站建设seo优化设计答案
  • wordpress 表格样式seo引擎优化工具
  • 网站建设吗排名前十的小说
  • 做淘宝客需要那先网站2022网络热词30个
  • 江阴网站优化公司搜索引擎优化核心
  • 上海seo推广服务广州seo公司品牌
  • 海口建设网站建设百度商品推广平台
  • 上海哪个网站专门做宝宝宴的搜索引擎优化有哪些要点
  • 少儿编程哪个机构比较好需要优化的地方
  • ps做网站ui免费外链代发平台
  • 在哪可以建一个网站网络营销推广策划书
  • wordpress 设置网站目录网页seo
  • 淄博专业网站建设哪家专业外链seo招聘
  • 凉山州住房和城乡建设局网站手机百度网页版入口