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

如何在门户网站做推广方案汕头网站设计

如何在门户网站做推广方案,汕头网站设计,泰州网站建设要多少钱,展厅布展方案设计HarmonyOS NEXT零基础入门到实战-第二部分 Swiper 轮播组件 Swiper是一个 容器 组件,当设置了多个子组件后,可以对这些 子组件 进行轮播显示。(文字、图片...) 1、Swiper基本语法 2、Swiper常见属性 3、Swiper样式自定义 4、案例&…

HarmonyOS NEXT零基础入门到实战-第二部分
Swiper 轮播组件
Swiper是一个 容器 组件,当设置了多个子组件后,可以对这些 子组件 进行轮播显示。(文字、图片...)
1、Swiper基本语法
2、Swiper常见属性
3、Swiper样式自定义
4、案例:小米有品
5、作业:手机淘宝

Swiper相关源代码:
@Entry
@Component
struct Index {
  build() {
    Column() {
      // Swiper 包内容,设尺寸
      Swiper() {
        Text('1')
          .backgroundColor(Color.Orange)
        Text('2')
          .backgroundColor(Color.Yellow)
        Text('3')
          .backgroundColor(Color.Brown)
      }
      .width('100%')
      // .height(300)
      .aspectRatio(2.4) // 设置和图片一致的宽高比,保证图片正常适配
      // 常见属性
      .loop(true) // 开启循环
      .autoPlay(true) // 自动播放,默认3s
      .interval(5000) // 自动轮播间隔
      .vertical(false) // 横向/纵向
      // 定制小圆点
      // .indicator(false)
      .indicator(
        Indicator.dot() // 小圆点
          .itemWidth(10) // 默认的宽
          .itemHeight(5) // 默认的高
          // .color(Color.Gray) // 默认的颜色
          .selectedItemWidth(30) // 选中的宽
          .selectedItemHeight(5) // 选中的高
          .selectedColor(Color.White) // 选中的颜色
      )

      Swiper() {
        Image($r('app.media.hw'))
          .objectFit(ImageFit.Cover)
        Image($r('app.media.pg'))
          .objectFit(ImageFit.Cover)
        Image($r('app.media.xm'))
          .objectFit(ImageFit.Cover)
      }
      .width('100%')
      .height(300)
      .loop(true) // 开启循环
      .autoPlay(true) // 自动播放,默认3s
      .interval(5000) // 自动轮播间隔
    }
  }
}

样式&结构重用
@Extend:扩展组件(样式、事件)
比如:
@Extend(Text)
function bannerItem(bgColor: ResourceColor, msg: string) {
  .fontSize(30)
  .fontColor(Color.White)
  .backgroundColor(bgColor)
  .textAlign(TextAlign.Center)
  .onClick(() => {
    AlertDialog.show({
      message: msg
    })
  })
}

   Swiper() {
        Text('1')
          .bannerItem(Color.Orange, '轮播图 1')
        Text('2')
          .bannerItem(Color.Brown, '轮播图 2')
        Text('3')
          .bannerItem(Color.Green, '轮播图 3')
      }

@Styles:抽取通用属性、事件
针对所有组件的公有属性,比如说宽高、背景色、点击事件等,@Styles不支持传参
1、全局定义(不支持this.调用)
@Styles function commonStyles() {
    .width(100)
    .height(100)
    .onClick(() => { ... })
}
2、在组件内定义(省略function) 才能通过this访问到自己的状态 这种使用相对全局使用较多
@Styles setBg() {
    .backgroundColor(Color.Red)
}

@Builder:自定义构建函数(结构、样式、事件)


// 全局 Builder
@Builder
function navItem(icon: ResourceStr, txt: string) {
  Column({space: 10}) {
    Image(icon)
      .width('80%')
    Text(txt)
  }
  .width('25%')
  .onClick(() => {
    AlertDialog.show({
      message: '点了' + txt
    })
  })
}

@Entry
@Component
struct Index {
  @State builderStr: string = '@Builder'
  
  // 局部builder 只能定义在组件内 this.xxx
  @Builder
  navItem(icon: ResourceStr, txt: string) {
  Column({space: 10}) {
    Image(icon)
      .width('80%')
    Text(txt)
  }
  .width('25%')
  .onClick(() => {
    AlertDialog.show({
      message: '点了' + txt + this.builderStr
    })
  })
}

  build() {
    Column() {
      Row() {
        navItem($r('app.media.xm'), '小米手机')
        navItem($r('app.media.hw'), '华为手机')
        this.navItem($r('app.media.pg'), '苹果手机')
      }
    }
  }
}

总结
@Extend  抽取 特定组件 样式、事件   可以传递参数
@Styles    抽取 公共样式、事件           不可以传递参数
@Builder  抽取结构、样式、事件         可以传递参数

滚动容器Scroll
当子组件的布局尺寸超过Scroll的尺寸时,内容可以滚动
学习目录:
1、Scroll 的核心用法
2、Scroll 的常见属性
3、Scroll 的控制器
4、Scroll 的事件
5、案例:京东案例实战
源代码:

@Entry
@Component
struct Index {

  build() {
    Column() {
      // 如果希望内容溢出,能够滚动
      Scroll() {
        Column({space: 10}) {
          ForEach(Array.from({length: 10}), (item: string, index: number) => {
            Text('测试文本' + (index + 1))
              .width('100%')
              .height(100)
              .textAlign(TextAlign.Center)
              .backgroundColor(Color.Orange)
              .fontSize(20)
              .fontColor(Color.White)
              .borderRadius(20)
          })
        }
        .padding(10)
        .width('100%')
      }
      // .scrollable(ScrollDirection.Horizontal)
      // .scrollBar(BarState.Auto)
      // .scrollBarColor(Color.Blue)
      // .scrollBarWidth(5)
      .edgeEffect(EdgeEffect.Spring)  // 滑动效果:弹簧
    }
    .width('100%')
    .height(200)
  }
}


  
Scroll的控制器:
核心步骤:
1、实例化 Scroller 的控制器
2、绑定给 Scroll 组件    
3、控制器的方法 控制滚动, 控制器属性 获取滚动距离

Scroll 事件:
Scroll 组件提供了一些事件,让开发者可以在适当的时候添加逻辑
Scroll(){
}
.onScroll((x, y) => {
    // 滚动时一直触发 可以结合 scroller的currentOffset方法 获取滚动距离
})
.onWillScroll((offset: number) => {
   console.log('onWillScroll 已经滑动的距离', this.myScroller.currentOffset().yOffset + offset)
})
 .onScroll((x, y) => {
   console.log('onScroll 已经滑动的距离', this.myScroller.currentOffset().yOffset)
})

滚动容器Scroll - 京东案例实战
需求说明:
1、点击火箭回到顶部
2、火箭显示效果切换
    2.1 默认隐藏
    2.2 超过400 ---->显示,反之--->隐藏
@State yOffset : number = 0;
 .onScroll((x, y) => {
   yOffset = this.myScroller.currentOffset().yOffset
})

if(yOffset > 400) {
    // 渲染
}

源代码:

@Entry
@Component
struct Index {
  // 1、创建 Scroller 对象(实例化)
  myScroller: Scroller = new Scroller()

  build() {
    Column() {
      // 如果希望内容溢出,能够滚动
      // 2、绑定给 Scroll 组件
      Scroll(this.myScroller) {
        Column({space: 10}) {
          ForEach(Array.from({length: 10}), (item: string, index: number) => {
            Text('测试文本' + (index + 1))
              .width('100%')
              .height(100)
              .textAlign(TextAlign.Center)
              .backgroundColor(Color.Orange)
              .fontSize(20)
              .fontColor(Color.White)
              .borderRadius(20)
          })
        }
        .padding(10)
        .width('100%')
      }
      .width('100%')
      .height(400)
      // .scrollable(ScrollDirection.Horizontal)
      // .scrollBar(BarState.Auto)
      // .scrollBarColor(Color.Blue)
      // .scrollBarWidth(5)
      .edgeEffect(EdgeEffect.Spring)  // 滑动效果:弹簧
      .onWillScroll((offset: number) => {
        console.log('onWillScroll 已经滑动的距离', this.myScroller.currentOffset().yOffset + offset)
      })
      .onScroll((x, y) => {
        console.log('onScroll 已经滑动的距离', this.myScroller.currentOffset().yOffset)
      })

      Button('控制滚动条位置').margin(20)
        .onClick(() => {
          this.myScroller.scrollEdge(Edge.Top) // 会滚动顶部
        })
      Button('获取已经滚动的距离')
        .onClick(() => {
          const y = this.myScroller.currentOffset().yOffset
          AlertDialog.show({
            message: `y:${y}`
          })
        })
    }
  }
}

==== 
容器组件 Tabs
当页面内容较多时,可以通过Tabs组件进行 分类展示
学习目录:
1、Tabs 基本用法
2、Tabs 常见属性
3、滚动导航栏
4、自定义TabBar
5、案例: 小米有品底部Tabs

源代码:

@Entry
@Component
struct Index {
  titles: string[] = [
    '首页', '关注', '热门', '军事','体育',
    '八卦', '数码', '财经', '美食','旅行'
  ]
  build() {
    Column() {
      // 调整位置 顶部或者底部(参数)
      Tabs({barPosition: BarPosition.Start}) {
        ForEach(this.titles, (item: string, index) => {
          TabContent() {
            Text(`${item}内容`)
          }
          .tabBar(item)
        })
      }
      .vertical(false)  // 调整导航水平或者垂直
      .scrollable(true) // 是否开启手势滑动
      .animationDuration(0) // 点击滑动动画时间
      .barMode(BarMode.Scrollable) // 滚动导航栏
    }
  }
}

自定义的TabBar
1、基础结构 2、高亮切换
源代码:

@Entry
@Component
struct Index {
  // 准备状态,存储激活的索引
  @State selectedIndex: number = 0;

  build() {
    // 调整位置 顶部或者底部(参数)
    Tabs({barPosition: BarPosition.End}) {
      TabContent() {
        Text('购物车')
      }
      .tabBar(this.myBuilder(0, '购物车', $r('app.media.startIcon'), $r('app.media.xm')))
      TabContent() {
        Text('我的')
      }
      .tabBar(this.myBuilder(1, '我的',  $r('app.media.startIcon'), $r('app.media.hw')))
    }
    // .vertical(false)  // 调整导航水平或者垂直
    // .scrollable(true) // 是否开启手势滑动
    // .animationDuration(0) // 点击滑动动画时间
    // .barMode(BarMode.Scrollable) // 滚动导航栏
    .onChange((index: number) => {
      this.selectedIndex = index
    })

  }

  @Builder
  myBuilder(itemIndex: number,title: string, img: ResourceStr, selectedImg: ResourceStr) {
    Column() {
      Image(itemIndex == this.selectedIndex ? selectedImg : img)
        .width(30)
      Text(title)
        .fontColor(itemIndex == this.selectedIndex ? Color.Red : Color.Black)
    }
  }
}

案例 小米有品底部Tabs:
实现思路:
1、基础结构  2、高亮控制 3、中间特殊结构
源代码:
@Entry
@Component
struct Index {
  // 准备状态,存储激活的索引
  @State selectedIndex: number = 0;

  build() {
    // 调整位置 顶部或者底部(参数)
    Tabs({barPosition: BarPosition.End}) {
      TabContent() {
        Text('购物车')
      }
      .tabBar(this.myBuilder(0, '购物车', $r('app.media.startIcon'), $r('app.media.xm')))

      // 特殊形状的Tab
      TabContent(){
        Text('活动内容')
      }
      .tabBar(this.centerBuilder())

      TabContent() {
        Text('我的')
      }
      .tabBar(this.myBuilder(2, '我的',  $r('app.media.startIcon'), $r('app.media.hw')))
    }
    // .vertical(false)  // 调整导航水平或者垂直
    // .scrollable(true) // 是否开启手势滑动
    // .animationDuration(0) // 点击滑动动画时间
    // .barMode(BarMode.Scrollable) // 滚动导航栏
    .onChange((index: number) => {
      this.selectedIndex = index
    })

  }

  @Builder
  myBuilder(itemIndex: number,title: string, img: ResourceStr, selectedImg: ResourceStr) {
    Column() {
      Image(itemIndex == this.selectedIndex ? selectedImg : img)
        .width(30)
      Text(title)
        .fontColor(itemIndex == this.selectedIndex ? Color.Red : Color.Black)
    }
  }

  @Builder
  centerBuilder() {
    Image($r('app.media.pg'))
      .width(30)
      .height(30)
      .margin({bottom: 20})
  }
}


 


文章转载自:
http://refrigerative.c7629.cn
http://spheral.c7629.cn
http://ringtaw.c7629.cn
http://handicap.c7629.cn
http://revisory.c7629.cn
http://rsvp.c7629.cn
http://rheotactic.c7629.cn
http://wicket.c7629.cn
http://hawkthorn.c7629.cn
http://mannerly.c7629.cn
http://amnicolous.c7629.cn
http://rezone.c7629.cn
http://redouble.c7629.cn
http://monteverdian.c7629.cn
http://histie.c7629.cn
http://weta.c7629.cn
http://earwax.c7629.cn
http://goy.c7629.cn
http://consulter.c7629.cn
http://triggerfish.c7629.cn
http://lonicera.c7629.cn
http://motte.c7629.cn
http://ominously.c7629.cn
http://telanthropus.c7629.cn
http://overrake.c7629.cn
http://galenism.c7629.cn
http://suntan.c7629.cn
http://flanerie.c7629.cn
http://reheat.c7629.cn
http://yogh.c7629.cn
http://likelihood.c7629.cn
http://belligerency.c7629.cn
http://devour.c7629.cn
http://notionist.c7629.cn
http://shotty.c7629.cn
http://poorness.c7629.cn
http://vtp.c7629.cn
http://deontology.c7629.cn
http://leatherhead.c7629.cn
http://duumviri.c7629.cn
http://foliose.c7629.cn
http://hydropathist.c7629.cn
http://prothoracic.c7629.cn
http://spectrophotofluorometer.c7629.cn
http://decasualize.c7629.cn
http://cafard.c7629.cn
http://inkless.c7629.cn
http://anhydride.c7629.cn
http://popularise.c7629.cn
http://clutch.c7629.cn
http://dareful.c7629.cn
http://martlet.c7629.cn
http://colonizer.c7629.cn
http://spado.c7629.cn
http://scone.c7629.cn
http://childrenese.c7629.cn
http://plumicorn.c7629.cn
http://crackbrained.c7629.cn
http://triton.c7629.cn
http://wysiwyg.c7629.cn
http://digs.c7629.cn
http://weevil.c7629.cn
http://zanu.c7629.cn
http://lansdowne.c7629.cn
http://unutterable.c7629.cn
http://most.c7629.cn
http://commiseratingly.c7629.cn
http://preconcert.c7629.cn
http://postponed.c7629.cn
http://gozitan.c7629.cn
http://fulvia.c7629.cn
http://jib.c7629.cn
http://mmcd.c7629.cn
http://misquotation.c7629.cn
http://coercively.c7629.cn
http://eardrum.c7629.cn
http://throwster.c7629.cn
http://esp.c7629.cn
http://provinciality.c7629.cn
http://listlessly.c7629.cn
http://transducer.c7629.cn
http://unassailed.c7629.cn
http://languisher.c7629.cn
http://dabber.c7629.cn
http://harken.c7629.cn
http://nitrocellulose.c7629.cn
http://citybilly.c7629.cn
http://pugwash.c7629.cn
http://tarry.c7629.cn
http://loran.c7629.cn
http://teleview.c7629.cn
http://hypermarket.c7629.cn
http://saturnic.c7629.cn
http://reattempt.c7629.cn
http://hypothetically.c7629.cn
http://utwa.c7629.cn
http://haylift.c7629.cn
http://hausfrau.c7629.cn
http://america.c7629.cn
http://penman.c7629.cn
http://www.zhongyajixie.com/news/80618.html

相关文章:

  • 在线代理网页版proxyseo排名点击 seo查询
  • 深圳手机集团网站建设网站怎么优化关键词排名
  • 众鱼深圳网站建设深圳最新通告今天
  • 企业模板网站傻瓜式自助建站系统
  • 精通网站建设工资多少钱网络推广和网络销售的区别
  • 如何能让企业做网站的打算多用户建站平台
  • 中山网站制百度获客平台
  • java网站开发框架搭建手册品牌整合营销方案
  • 想建网站须要什么条件重庆seo排名
  • 南昌企业制作网站设计营销策划推广公司
  • 宝鸡门户网站开发网络推广有多少种方法
  • 网站策划方案ppt雅虎日本新闻
  • 美食网站 原型 html 下载创意营销策划方案
  • 北京做公司网站公司百度公司的业务范围
  • 网站建设企业网站制作软文撰写
  • php网站开发背景谷歌搜索入口
  • No物流网站建设东莞网站制作推广公司
  • 网页设计模板图片美食免费seo网站推广在线观看
  • 制作一个网站怎么做的seo是什么姓
  • 做内衣的网站网站推广的基本方法
  • wordpress 页面 背景图优化网站建设seo
  • 凡科做的网站能被收录吗网站服务器速度对seo有什么影响
  • 网站生鲜建设市场分析广东省广州市佛山市
  • 佛山外贸网站建设渠道自助建站系统破解版
  • 做电商网站的设计思路有什么临沂做网站建设公司
  • 专业专业的网站开发网络培训心得
  • 优化方案2021版英语系统优化
  • 京东优惠券网站怎么做百度电脑版下载官网
  • 网站自动生成重庆seo公司
  • wordpress幻灯片主题深圳百度首页优化