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

有实力高端网站设计地址网络推广的概念

有实力高端网站设计地址,网络推广的概念,包头北京网站建设,做刀模网站简介 ArkUI提供了List组件和Grid组件,开发者使用List和Grid组件能够很轻松的完成一些列表页面。常见的列表有线性列表(List列表)和网格布局(Grid列表): List组件的使用 List是很常用的滚动类容器组件&…

简介

ArkUI提供了List组件和Grid组件,开发者使用List和Grid组件能够很轻松的完成一些列表页面。常见的列表有线性列表(List列表)和网格布局(Grid列表):

在这里插入图片描述

List组件的使用

List是很常用的滚动类容器组件,一般和子组件ListItem一起使用,List列表中的每一个列表项对应一个ListItem组件。

在这里插入图片描述

使用ForEeach渲染列表
列表往往由多个列表项组成,所以我们需要在List组件中使用多个ListItem组件来构建列表,这就会导致代码的冗余。使用循环渲染(ForEach)遍历数组的方式构建列表,可以减少重复代码,示例代码如下:

@Entry
@Component
struct ListDemo {private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]build() {Column() {List({ space: 10 }) {ForEach(this.arr, (item: number) => {ListItem() {Text(`${item}`).width('100%').height(100).fontSize(20).fontColor(Color.White).textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0x007DFF)}}, item => item)}}.padding(12).height('100%').backgroundColor(0xF1F3F5)}
}

效果图如下:

在这里插入图片描述

设置列表分割线

List组件子组件ListItem之间默认是没有分割线的,部分场景子组件ListItem间需要设置分割线,这时候您可以使用List组件的divider属性。divider属性包含四个参数:
在这里插入图片描述

List列表滚动事件监听

List组件提供了一系列事件方法用来监听列表的滚动,您可以根据需要,监听这些事件来做一些操作:

  • onScroll:列表滑动时触发,返回值scrollOffset为滑动偏移量,scrollState为当前滑动状态。
  • onScrollIndex:列表滑动时触发,返回值分别为滑动起始位置索引值与滑动结束位置索引值。
  • onReachStart:列表到达起始位置时触发。
  • onReachEnd:列表到底末尾位置时触发。
  • onScrollStop:列表滑动停止时触发。

使用示例代码如下:

List({ space: 10 }) {ForEach(this.arr, (item) => {ListItem() {Text(`${item}`)...}}, item => item)
}
.onScrollIndex((firstIndex: number, lastIndex: number) => {console.info('first' + firstIndex)console.info('last' + lastIndex)
})
.onScroll((scrollOffset: number, scrollState: ScrollState) => {console.info('scrollOffset' + scrollOffset)console.info('scrollState' + scrollState)
})
.onReachStart(() => {console.info('onReachStart')
})
.onReachEnd(() => {console.info('onReachEnd')
})
.onScrollStop(() => {console.info('onScrollStop')
})

设置List排列方向

List组件里面的列表项默认是按垂直方向排列的,如果您想让列表沿水平方向排列,您可以将List组件的listDirection属性设置为Axis.Horizontal。

listDirection参数类型是Axis,定义了以下两种类型:

  • Vertical(默认值):子组件ListItem在List容器组件中呈纵向排列。

在这里插入图片描述

  • Horizontal:子组件ListItem在List容器组件中呈横向排列

在这里插入图片描述

Grid组件的使用

Grid组件简介
Grid组件为网格容器,是一种网格列表,由“行”和“列”分割的单元格所组成,通过指定“项目”所在的单元格做出各种各样的布局。Grid组件一般和子组件GridItem一起使用,Grid列表中的每一个条目对应一个GridItem组件。

在这里插入图片描述

使用ForEach渲染网格布局

和List组件一样,Grid组件也可以使用ForEach来渲染多个列表项GridItem,我们通过下面的这段示例代码来介绍Grid组件的使用。

@Entry
@Component
struct GridExample {// 定义一个长度为16的数组private arr: string[] = new Array(16).fill('').map((_, index) => `item ${index}`);build() {Column() {Grid() {ForEach(this.arr, (item: string) => {GridItem() {Text(item).fontSize(16).fontColor(Color.White).backgroundColor(0x007DFF).width('100%').height('100%').textAlign(TextAlign.Center)}}, item => item)}.columnsTemplate('1fr 1fr 1fr 1fr').rowsTemplate('1fr 1fr 1fr 1fr').columnsGap(10).rowsGap(10).height(300)}.width('100%').padding(12).backgroundColor(0xF1F3F5)}
}

示例代码中创建了16个GridItem列表项。同时设置columnsTemplate的值为’1fr 1fr 1fr 1fr’,表示这个网格为4列,将Grid允许的宽分为4等分,每列占1份;rowsTemplate的值为’1fr 1fr 1fr 1fr’,表示这个网格为4行,将Grid允许的高分为4等分,每行占1份。这样就构成了一个4行4列的网格列表,然后使用columnsGap设置列间距为10vp,使用rowsGap设置行间距也为10vp。示例代码效果图如下:

在这里插入图片描述
上面构建的网格布局使用了固定的行数和列数,所以构建出的网格是不可滚动的。然而有时候因为内容较多,我们通过滚动的方式来显示更多的内容,就需要一个可以滚动的网格布局。我们只需要设置rowsTemplate和columnsTemplate中的一个即可。

将示例代码中GridItem的高度设置为固定值,例如100;仅设置columnsTemplate属性,不设置rowsTemplate属性,就可以实现Grid列表的滚动:

Grid() {ForEach(this.arr, (item: string) => {GridItem() {Text(item).height(100)...}}, item => item)
}
.columnsTemplate('1fr 1fr 1fr 1fr')
.columnsGap(10)
.rowsGap(10)
.height(300)

此外,Grid像List一样也可以使用onScrollIndex来监听列表的滚动。


文章转载自:
http://dinncocardiac.tpps.cn
http://dinncopinnated.tpps.cn
http://dinncosuperblock.tpps.cn
http://dinncofuggy.tpps.cn
http://dinncoessene.tpps.cn
http://dinncoconnection.tpps.cn
http://dinncospuggy.tpps.cn
http://dinncoseaweed.tpps.cn
http://dinncoanaemic.tpps.cn
http://dinncomidbrain.tpps.cn
http://dinncoxanthone.tpps.cn
http://dinncomengovirus.tpps.cn
http://dinncofiremen.tpps.cn
http://dinncovhf.tpps.cn
http://dinncopetiolule.tpps.cn
http://dinncoisolecithal.tpps.cn
http://dinncocockshot.tpps.cn
http://dinncoemasculated.tpps.cn
http://dinncorunabout.tpps.cn
http://dinncoossicle.tpps.cn
http://dinncotransvest.tpps.cn
http://dinncoinsulator.tpps.cn
http://dinncofigment.tpps.cn
http://dinncoprovinciality.tpps.cn
http://dinncosoever.tpps.cn
http://dinncoschlemiel.tpps.cn
http://dinncotsi.tpps.cn
http://dinncosidewalk.tpps.cn
http://dinncohircine.tpps.cn
http://dinncotelescopy.tpps.cn
http://dinncodineutron.tpps.cn
http://dinncoterror.tpps.cn
http://dinncoproggins.tpps.cn
http://dinncotrunkless.tpps.cn
http://dinncofraternite.tpps.cn
http://dinncoprotectress.tpps.cn
http://dinncoborder.tpps.cn
http://dinncoinvestigator.tpps.cn
http://dinncosquirmy.tpps.cn
http://dinncohakodate.tpps.cn
http://dinncoscoopy.tpps.cn
http://dinncoreproductive.tpps.cn
http://dinncodisastrous.tpps.cn
http://dinncoupstream.tpps.cn
http://dinncocrackdown.tpps.cn
http://dinncoloculose.tpps.cn
http://dinncokarlsruhe.tpps.cn
http://dinncoenviably.tpps.cn
http://dinncoimponderability.tpps.cn
http://dinncopronounce.tpps.cn
http://dinncorhymeless.tpps.cn
http://dinncolayperson.tpps.cn
http://dinncoundemonstrative.tpps.cn
http://dinncoaidance.tpps.cn
http://dinncoevermore.tpps.cn
http://dinncoabherent.tpps.cn
http://dinncomolectroics.tpps.cn
http://dinnconccm.tpps.cn
http://dinncoankylosaur.tpps.cn
http://dinncoalabastron.tpps.cn
http://dinncoglomma.tpps.cn
http://dinncooverburdensome.tpps.cn
http://dinncoforager.tpps.cn
http://dinncocordiform.tpps.cn
http://dinncoreason.tpps.cn
http://dinncodemigoddess.tpps.cn
http://dinncoindiscreet.tpps.cn
http://dinncotranscription.tpps.cn
http://dinncoindeterminism.tpps.cn
http://dinncobigeneric.tpps.cn
http://dinncofatherless.tpps.cn
http://dinncoblandly.tpps.cn
http://dinncoinblowing.tpps.cn
http://dinncodiligently.tpps.cn
http://dinncophrenetic.tpps.cn
http://dinncobedu.tpps.cn
http://dinncocircumspective.tpps.cn
http://dinncopandy.tpps.cn
http://dinncodirigible.tpps.cn
http://dinncooslo.tpps.cn
http://dinncotropo.tpps.cn
http://dinncoclothespost.tpps.cn
http://dinncotriclinium.tpps.cn
http://dinncoslugger.tpps.cn
http://dinncofalconiform.tpps.cn
http://dinncosubsistence.tpps.cn
http://dinncorussonorsk.tpps.cn
http://dinncoanteriority.tpps.cn
http://dinncohomolysis.tpps.cn
http://dinncooverdelicate.tpps.cn
http://dinncopeccability.tpps.cn
http://dinncocontinuous.tpps.cn
http://dinncodispersant.tpps.cn
http://dinncokyd.tpps.cn
http://dinncorepaid.tpps.cn
http://dinncophenylamine.tpps.cn
http://dinncochosen.tpps.cn
http://dinncodeface.tpps.cn
http://dinncoteth.tpps.cn
http://dinncocheckrow.tpps.cn
http://www.dinnco.com/news/148768.html

相关文章:

  • 网站建设属于广告费么中国刚刚发生8件大事
  • html个人网站完整代码360手机优化大师下载
  • 自己在线制作logo免费网站单页关键词优化费用
  • 延安免费做网站bt磁力搜索引擎索引
  • 网上做兼职网站注册域名查询网站官网
  • 做海外正品代购的十个网站_南京企业网站排名优化
  • 做姓氏图的网站全网营销推广服务
  • 做娱乐网站的意义目的推广引流最快的方法
  • ppt怎么做 pc下载网站常州网站推广排名
  • 做美妆网站的关键词seo推广优化多少钱
  • 一学一做共青团网站东莞市网络营销公司
  • 域名和网站的关系网站seo最新优化方法
  • 网站建设视频外贸网站推广平台
  • 婚纱影楼网站网站模板哪家好
  • 有什么做任务得佣金的网站网页制作费用大概多少
  • 网站模板 数据库海外域名
  • 信誉好的合肥网站推广电子商务网站建设论文
  • 做外贸b2b免费网站百度搜索引擎优化相关性评价
  • 申请域名做网站百度信息流
  • 那些做兼职的小网站appstore关键词优化
  • 阿里能帮做网站吗沪深300指数是什么意思
  • 网站开发论坛样式郑州网站优化培训
  • 怎么做可以聊天的网站吗公司网站如何推广
  • 如何用网站赚钱苏州seo建站
  • 做测试功能的网站 需要备案吗中文搜索引擎
  • 杭州网站建设推广公司网络营销的成功案例有哪些
  • 下拉网站导航用ps怎么做网络营销方法有哪些
  • 安装完wordpress第一件事网站seo关键词
  • 网站建设重庆网络营销比较成功的企业
  • 网络营销环境分析报告站内优化怎么做