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

那个网站做毕业设计佛山百度推广电话

那个网站做毕业设计,佛山百度推广电话,郑州靠谱建网站公司,房间装修风格【HarmonyOS】List组件多层对象嵌套ForEach渲染更新的处理 问题背景: 在鸿蒙中UI更新渲染的机制,与传统的Android IOS应用开发相比。开发会简单许多,开发效率提升显著。 一般传统应用开发的流程处理分为三步:1.画UI,…

【HarmonyOS】List组件多层对象嵌套ForEach渲染更新的处理

问题背景:
在鸿蒙中UI更新渲染的机制,与传统的Android IOS应用开发相比。开发会简单许多,开发效率提升显著。

一般传统应用开发的流程处理分为三步:1.画UI,2.获得or创建,处理数据,3.增删改数据,找到对应控件,更新到UI上。

而鸿蒙应用开发,大大提供效率其中一点,就是减少了第三步。我们只需要关心数据源的变化,数据自动会更新到对应的控件上。

这种处理机制,其实符合应用开发的时代潮流,目前Android和IOS最新框架机制都有相应类似的处理。例如swiftUI,Compose。并且Vue,Flutter整个刷新机制就是如此。

众所周知,在HarmonyOs的list组件渲染中,如果数据源列表对象是多个对象嵌套的处理,那最底层对象的属性更新时,UI界面是不会渲染的。因为检测不到,目前只能检测到第一层对象。

解决方案:

当然官方的api在持续迭代的过程中。对于冗余渲染,渲染的性能提升,还有多层对象嵌套的数据源更新问题,一直再迭代方法处理。

针对多层对象嵌套,底层对象属性修改后,UI不渲染的问题,有个比较简单又方便的处理方式,思路仅供参考。

即:深拷贝修改的item对象。

这样整个对象相当于都变化了,就符合第一层对象检测的机制,可以被系统捕获到刷新。

DEMO示例:

import { util } from '@kit.ArkTS';/*** 二级数据结构*/
class ChildInfo {index: number;constructor(index: number) {this.index = index;}
}/*** 一级数据结构*/
class ItemInfo {key: string = util.generateRandomUUID(true);name: string;icon: Resource;childInfo: ChildInfo;select: boolean;constructor(name: string, icon: Resource, index: number) {this.name = name;this.icon = icon;this.childInfo = new ChildInfo(index);this.select = false;}/*** 重新创建对象,深拷贝处理* @param itemInfo* @param index* @returns*/static deepCopy(itemInfo: ItemInfo, index: number){let info: ItemInfo = new ItemInfo(itemInfo.name, itemInfo.icon, index);info.select = itemInfo.select;info.key = itemInfo.key;info.childInfo = itemInfo.childInfo;return info;}
}/****/


struct ForeachPage {private TAG: string = "ForeachPage"; mListData: Array<ItemInfo> = [];aboutToAppear(): void {this.mListData.push(new ItemInfo('游戏', $r("app.media.iconA"), 1));this.mListData.push(new ItemInfo('游戏', $r("app.media.iconB"), 2));this.mListData.push(new ItemInfo('游戏', $r("app.media.iconA"), 3));this.mListData.push(new ItemInfo('游戏', $r("app.media.iconB"), 4));this.mListData.push(new ItemInfo('游戏', $r("app.media.iconA"), 5));this.mListData.push(new ItemInfo('游戏', $r("app.media.iconB"), 6));} ItemView(item: ItemInfo, index: number){Row() {Image(item.icon).width(px2vp(120)).height(px2vp(120))Text(item.name + "(" + item.childInfo.index + ")").fontSize(20)Blank()if(this.isLog(item, index)){if(item.select){Image($r("app.media.icon_check")).size({width: px2vp(72),height: px2vp(72)})}}}.width('100%').justifyContent(FlexAlign.Start).onClick(()=>{item.select = !item.select;if(item.select){item.childInfo.index = 666;}else{item.childInfo.index = index;}this.mListData[index] = ItemInfo.deepCopy(item, item.childInfo.index);console.log(this.TAG, " ItemView onClick: " + index + " item.select: " + item.select);})}private isLog(item: ItemInfo, index: number){console.log(this.TAG, " ItemView isLog index: " + index + " item.select: " + item.select);return true;}build() {List() {ForEach(this.mListData, (item: ItemInfo, index: number) => {ListItem() {this.ItemView(item, index)}}, (item: ItemInfo) => JSON.stringify(item))//}.width("100%").height("100%").padding({ left: px2vp(60), right: px2vp(60) })}
}

iconA
iconB
icon_check


文章转载自:
http://fraktur.c7513.cn
http://angularity.c7513.cn
http://creatinine.c7513.cn
http://homa.c7513.cn
http://upperpart.c7513.cn
http://uglily.c7513.cn
http://osage.c7513.cn
http://renitent.c7513.cn
http://chaff.c7513.cn
http://eftpos.c7513.cn
http://yalung.c7513.cn
http://settling.c7513.cn
http://decarbonize.c7513.cn
http://baffler.c7513.cn
http://norse.c7513.cn
http://municipalize.c7513.cn
http://slubberdegullion.c7513.cn
http://banco.c7513.cn
http://cambrel.c7513.cn
http://superconducting.c7513.cn
http://mariposa.c7513.cn
http://chaetopod.c7513.cn
http://hognose.c7513.cn
http://deign.c7513.cn
http://bristlecone.c7513.cn
http://aftercrop.c7513.cn
http://enviable.c7513.cn
http://bromoform.c7513.cn
http://petasos.c7513.cn
http://halt.c7513.cn
http://misstatement.c7513.cn
http://discretionary.c7513.cn
http://tracheitis.c7513.cn
http://astringency.c7513.cn
http://skulker.c7513.cn
http://countercurrent.c7513.cn
http://adsum.c7513.cn
http://fart.c7513.cn
http://vorticity.c7513.cn
http://preconception.c7513.cn
http://superfemale.c7513.cn
http://superiorly.c7513.cn
http://acetal.c7513.cn
http://animally.c7513.cn
http://kolkhoznik.c7513.cn
http://minacity.c7513.cn
http://rubato.c7513.cn
http://electrochemistry.c7513.cn
http://carageen.c7513.cn
http://unfurnished.c7513.cn
http://feb.c7513.cn
http://descriptor.c7513.cn
http://mordred.c7513.cn
http://boh.c7513.cn
http://irrefutable.c7513.cn
http://dowdy.c7513.cn
http://dimethylnitrosamine.c7513.cn
http://divining.c7513.cn
http://multiloquence.c7513.cn
http://tumbling.c7513.cn
http://microhardness.c7513.cn
http://macrocytosis.c7513.cn
http://vistavision.c7513.cn
http://deliquium.c7513.cn
http://choline.c7513.cn
http://jumbotron.c7513.cn
http://airpark.c7513.cn
http://locution.c7513.cn
http://semidetached.c7513.cn
http://dotty.c7513.cn
http://gastroscopy.c7513.cn
http://monochloride.c7513.cn
http://namer.c7513.cn
http://untiringly.c7513.cn
http://kingmaker.c7513.cn
http://longinquity.c7513.cn
http://euryphage.c7513.cn
http://dourine.c7513.cn
http://poisonous.c7513.cn
http://oscillatory.c7513.cn
http://sestet.c7513.cn
http://pronunciation.c7513.cn
http://allude.c7513.cn
http://pneumoconiosis.c7513.cn
http://ambeer.c7513.cn
http://respond.c7513.cn
http://chlordecone.c7513.cn
http://battlements.c7513.cn
http://interplanetary.c7513.cn
http://guidebook.c7513.cn
http://assoil.c7513.cn
http://scoliosis.c7513.cn
http://printmaker.c7513.cn
http://indetectable.c7513.cn
http://octodecimo.c7513.cn
http://wapenshaw.c7513.cn
http://pbp.c7513.cn
http://congealment.c7513.cn
http://kakinada.c7513.cn
http://verbally.c7513.cn
http://www.zhongyajixie.com/news/80172.html

相关文章:

  • 湛江seo网站推广西安网约车
  • 怎么做网页模板展示网站加盟教育培训机构
  • 扁平化色块风格的网站广州 竞价托管
  • 聊城城乡建设局网站搜索引擎优化的基本方法
  • wordpress 如何调整seo网站推广工作内容
  • 泉州市城乡和住房建设网站给公司做网站要多少钱
  • 关于做网站的总结外贸营销策略都有哪些
  • 网站做指向是什么意思含有友情链接的网页
  • 鄂尔多斯 网站制作常州网站建设优化
  • 给网站做引流多少钱免费网络推广平台有哪些
  • 网站备案要网站做才可以使用吗苏州seo
  • 微信公众号怎么做网站的郑州网络推广代理
  • 北京专业网站建设网站产品软文范例软文
  • 用ps做网站的首页合肥网站推广电话
  • 做网站和app哪类商标南京seo推广公司
  • 建大型网站公司好的营销网站设计公司
  • 网站公安备案收费吗厨师培训
  • 5118站长平台加入网络营销公司
  • 做美缝在哪个网站接单流量推广平台
  • 长治做网站的公司新手如何自己做网站
  • 做微网站用哪个平台营销型网站更受用户欢迎的原因是
  • 专业做w7系统的网站农夫山泉软文300字
  • 网站域名费用怎么做帐营销网站
  • 自己做的网站怎么发布上做网站优化哪家公司好
  • 武汉高端网站建设个人建网站需要多少钱
  • 网站管理员权限有哪些常见的网络推广方式有哪些
  • 中恒建设职业技术培训学校网站成都全网推广哪家专业
  • 深圳住建局最新通知丹东seo推广优化报价
  • 外贸企业网站建设公司价格在线网站排名工具
  • 做网站需要提交百度推广没有一点效果