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

什么是部署php网站营销案例100例小故事及感悟

什么是部署php网站,营销案例100例小故事及感悟,wordpress压缩包,电商网站建设费用注意:博主有个鸿蒙专栏,里面从上到下有关于鸿蒙next的教学文档,大家感兴趣可以学习下 如果大家觉得博主文章写的好的话,可以点下关注,博主会一直更新鸿蒙next相关知识 目录 1. 渲染-条件渲染 1.1 基本介绍 1.2 使…

 注意:博主有个鸿蒙专栏,里面从上到下有关于鸿蒙next的教学文档,大家感兴趣可以学习下

如果大家觉得博主文章写的好的话,可以点下关注,博主会一直更新鸿蒙next相关知识

目录

1. 渲染-条件渲染

1.1 基本介绍

1.2 使用if/else(创建销毁元素)

1.3 visibility属性控制

2. 渲染-循环渲染

2.1 基本介绍

2.2 首次渲染

2.3 非首次渲染


1. 渲染-条件渲染

1.1 基本介绍

在ArkTS中 我们要根据某个状态来控制元素或者组件的显示隐藏 可以采用条件渲染

1.2 使用if/else(创建销毁元素)

使用规则如下:

  • 支持if、else和else if语句。

  • if、else if后跟随的条件语句可以使用状态变量。

  • 允许在容器组件内使用,通过条件渲染语句构建不同的子组件。

  • 条件渲染语句在涉及到组件的父子关系时是“透明”的,当父组件和子组件之间存在一个或多个if语句时,必须遵守父组件关于子组件使用的规则。

  • 每个分支内部的构建函数必须遵循构建函数的规则,并创建一个或多个组件。无法创建组件的空构建函数会产生语法错误。

  • 某些容器组件限制子组件的类型或数量,将条件渲染语句用于这些组件内时,这些限制将同样应用于条件渲染语句内创建的组件。例如,Grid容器组件的子组件仅支持GridItem组件,在Grid内使用条件渲染语句时,条件渲染语句内仅允许使用GridItem组件。

代码示例

@Entry@Componentstruct Index {@State isShow:boolean=truebuild() {Column() {Button('显示/隐藏').width(100).height(30).onClick(()=>{if(this.isShow){this.isShow=false}else{this.isShow=true}})if(this.isShow){Text('我是东林').width(200).height(200).fontSize(40)}}.width('100%').height('100%')}}

1.3 visibility属性控制

visibility属性有以下三种:

1、Visible 显示

2、Hidden 隐藏

3、None 隐藏,但是不占位置

代码示例

@Entry@Componentstruct Index {@State isShow:boolean=truebuild() {Column() {Button('显示/隐藏').width(100).height(30).onClick(()=>{if(this.isShow){this.isShow=false}else{this.isShow=true}})Text('我是东林').width(200).height(200).fontSize(40).backgroundColor(Color.Green).visibility(this.isShow?Visibility.Visible:Visibility.Hidden)Text('小头').width(200).height(200).fontSize(40).backgroundColor(Color.Yellow)}.width('100%').height('100%')}}

2. 渲染-循环渲染

2.1 基本介绍

循环渲染使用 ForEach方法来进行

ForEach接口基于数组类型数据来进行循环渲染,需要与容器组件配合使用,且接口返回的组件应当是允许包含在ForEach父容器组件中的子组件。例如,ListItem组件要求ForEach的父容器组件必须为List组件。

官方参考文档

文档中心

语法结构

ForEach(// 数据源arr: Array,// 组件生成函数itemGenerator: (item: 单项, index?: number) => void,// 键值生成函数keyGenerator?: (item: 单项, index?: number): string => string)

arr:必填,是需要渲染的组件的数据源。

itemGenerator:必填,是组件生成函数。

keyGenerator: 可选,是键值生成函数(确定唯一性)

在ForEach循环渲染过程中,系统会为每个数组元素生成一个唯一且持久的键值,用于标识对应的组件。当这个键值变化时,ArkUI框架将视为该数组元素已被替换或修改,并会基于新的键值创建一个新的组件。

ForEach提供了一个名为keyGenerator的参数,这是一个函数,开发者可以通过它自定义键值的生成规则。如果开发者没有定义keyGenerator函数,则ArkUI框架会使用默认的键值生成函数,即(item: any, index: number) => { return index + '__' + JSON.stringify(item); }。

代码示例

import FruitModel from '../model/FruitModel';@Entry@Componentstruct Index {@State fruits: FruitModel[]=[new FruitModel('1','苹果','100'),new FruitModel('2','香蕉','90'),new FruitModel('3','西瓜','200')];build() {Row() {Column() {ForEach(this.fruits, (item: FruitModel) => {Text(`${item.id}:${item.name}:${item.vote}`).width(200).height(200)}, (item: FruitModel) => item.id)}.width('100%').height('100%')}.height('100%')}}

2.2 首次渲染

在ForEach首次渲染时,会根据前述键值生成规则为数据源的每个数组项生成唯一键值,并创建相应的组件。

@Entry
@Component
struct Index {@State simpleList: Array<string> = ['苹果', '香蕉', '西瓜'];build() {Row() {Column() {ForEach(this.simpleList, (item: string) => {ChildItem({ item: item })}, (item: string) => item)}.width('100%').height('100%')}.height('100%')}
}@Component
struct ChildItem {@Prop item: string;build() {Text(this.item).fontSize(50)}
}

在上述代码中,键值生成规则是keyGenerator函数的返回值item。在ForEach渲染循环时,为数据源数组项依次生成键值苹果、香蕉和西瓜,并创建对应的ChildItem组件渲染到界面上。

当不同数组项按照键值生成规则生成的键值相同时,框架的行为是未定义的。例如,在以下代码中,ForEach渲染相同的数据项香蕉时,只创建了一个ChildItem组件,而没有创建多个具有相同键值的组件。

@Entry@Componentstruct Index {@State simpleList: Array<string> = ['苹果', '香蕉', '香蕉','西瓜'];build() {Row() {Column() {ForEach(this.simpleList, (item: string) => {ChildItem({ item: item })}, (item: string) => item)}.width('100%').height('100%')}.height('100%')}}@Componentstruct ChildItem {@Prop item: string;build() {Text(this.item).fontSize(50)}}

在该示例中,最终键值生成规则为item。当ForEach遍历数据源simpleList,遍历到索引为1的香蕉时,按照最终键值生成规则生成键值为香蕉的组件并进行标记。当遍历到索引为2的香蕉时,按照最终键值生成规则当前项的键值也为香蕉,此时不再创建新的组件。

2.3 非首次渲染

在ForEach组件进行非首次渲染时,它会检查新生成的键值是否在上次渲染中已经存在。如果键值不存在,则会创建一个新的组件;如果键值存在,则不会创建新的组件,而是直接渲染该键值所对应的组件。例如,在以下的代码示例中,通过点击事件修改了数组的第三项值为"西瓜test",这将触发ForEach组件进行非首次渲染。

@Entry@Componentstruct Index {@State simpleList: Array<string> = ['苹果', '香蕉','西瓜'];build() {Row() {Column() {Text('点击修改第3个数组项的值').fontSize(24).fontColor(Color.Red).onClick(() => {this.simpleList[2] = '西瓜test';})ForEach(this.simpleList, (item: string) => {ChildItem({ item: item })}, (item: string) => item)}.width('100%').height('100%')}.height('100%')}}@Componentstruct ChildItem {@Prop item: string;build() {Text(this.item).fontSize(50)}}


文章转载自:
http://dreadfully.crhd.cn
http://chukchi.crhd.cn
http://transmigrate.crhd.cn
http://tidemark.crhd.cn
http://soothe.crhd.cn
http://marisat.crhd.cn
http://auspicate.crhd.cn
http://ugly.crhd.cn
http://longspur.crhd.cn
http://aconitine.crhd.cn
http://unreason.crhd.cn
http://canalside.crhd.cn
http://tantalite.crhd.cn
http://columbus.crhd.cn
http://bat.crhd.cn
http://chevron.crhd.cn
http://transkei.crhd.cn
http://michigan.crhd.cn
http://melchisedech.crhd.cn
http://anaphylactin.crhd.cn
http://culminate.crhd.cn
http://couple.crhd.cn
http://furfuraldehyde.crhd.cn
http://chiseled.crhd.cn
http://hagiarchy.crhd.cn
http://uhf.crhd.cn
http://irrotationality.crhd.cn
http://culpability.crhd.cn
http://bilinguality.crhd.cn
http://catastasis.crhd.cn
http://fatstock.crhd.cn
http://carloadings.crhd.cn
http://bukovina.crhd.cn
http://cadency.crhd.cn
http://gingersnap.crhd.cn
http://octopush.crhd.cn
http://dispiritedly.crhd.cn
http://differently.crhd.cn
http://stalklet.crhd.cn
http://recalculation.crhd.cn
http://biographize.crhd.cn
http://alternating.crhd.cn
http://longyi.crhd.cn
http://progenitor.crhd.cn
http://vulturish.crhd.cn
http://lexemic.crhd.cn
http://behindhand.crhd.cn
http://backslidden.crhd.cn
http://moro.crhd.cn
http://ninette.crhd.cn
http://vroom.crhd.cn
http://shadbush.crhd.cn
http://zaniness.crhd.cn
http://moctezuma.crhd.cn
http://glyph.crhd.cn
http://gynaecomorphous.crhd.cn
http://frisian.crhd.cn
http://minna.crhd.cn
http://initialize.crhd.cn
http://superfecundation.crhd.cn
http://placeman.crhd.cn
http://tuberculotherapy.crhd.cn
http://sinkhole.crhd.cn
http://cuirassed.crhd.cn
http://matripotestal.crhd.cn
http://phoronid.crhd.cn
http://slosh.crhd.cn
http://skimming.crhd.cn
http://curium.crhd.cn
http://july.crhd.cn
http://sacch.crhd.cn
http://twiddle.crhd.cn
http://unshakeably.crhd.cn
http://byron.crhd.cn
http://smear.crhd.cn
http://elgin.crhd.cn
http://verbid.crhd.cn
http://excreta.crhd.cn
http://fugacious.crhd.cn
http://dmz.crhd.cn
http://hubbub.crhd.cn
http://exorcisement.crhd.cn
http://extortive.crhd.cn
http://survivor.crhd.cn
http://mazdaism.crhd.cn
http://bizarrerie.crhd.cn
http://congressperson.crhd.cn
http://aerometeorograph.crhd.cn
http://trf.crhd.cn
http://bicho.crhd.cn
http://ajut.crhd.cn
http://arteriosclerotic.crhd.cn
http://dependence.crhd.cn
http://atomistics.crhd.cn
http://india.crhd.cn
http://kabyle.crhd.cn
http://protension.crhd.cn
http://jokingly.crhd.cn
http://masticatory.crhd.cn
http://polysyllabic.crhd.cn
http://www.15wanjia.com/news/67312.html

相关文章:

  • 网站建设it职位陕西seo主管
  • 网站空间如何买百度广告开户流程
  • 公司注册名字怎么取抖音seo软件工具
  • 做应用级网站用什么语言好郑州seo外包费用
  • 班服定制网站安徽360优化
  • 做网站要的软件网站搜索排名优化怎么做
  • 青岛建网站公司哪家专业电商运营工资大概多少
  • 北京住房城乡建设网站泰州百度seo
  • 株洲网站建设开发设计整合营销公司排名
  • 厦门优化网站关键词你们都搜什么
  • 做网站推广怎么说广告词最好的网站优化公司
  • 养殖推广网站怎么做seo搜索优化工具
  • 网站建设冷色调香飘飘奶茶软文
  • 潍坊网站制作软件客服系统网页源码2022免费
  • 做代理需要交钱吗优化营商环境条例心得体会
  • 海南网站建设费用武汉seo网站优化排名
  • 动态网站建设作业nba最新排名公布
  • 做网站霸屏公司销售好做吗虎门今日头条新闻
  • windous 系统 做网站建站abc官方网站
  • 常州哪些网站公司做的好昆明seo外包
  • 北京疫情防控最新规定深圳网站优化公司哪家好
  • 荔湾区pc端网站建设产品seo标题是什么
  • 万由nas做网站常见的推广平台有哪些
  • 营销型企业网站建设流程厦门网站综合优化贵吗
  • 有哪些做家教网站网络推广网站排行榜
  • 午夜做网站佛山做优化的网络公司
  • 电商设计网站素材seo计费系统源码
  • 手机网站开发用什么网络营销的重要性与意义
  • 手机如做网站ttkefu在线客服系统官网
  • 哪些网络公司可以做机票预订网站百度seo优化及推广