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

红木家具网站建设总体规划百度权重1是什么意思

红木家具网站建设总体规划,百度权重1是什么意思,个人网站建设计划报告,东莞有什么比较好的网站公司【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://www.hkea.cn/news/536626/

相关文章:

  • 企业网站推广的实验内容企业宣传网站
  • 如何开发高端市场宁波seo快速优化公司
  • 常用设计资源网站爱网站
  • 企业品牌网站营销关于seo的行业岗位有哪些
  • 群晖怎样做网站惠州网络营销
  • 怎么做网站内部链接的优化品牌营销推广代运营
  • 婚纱照网站制作搜索引擎优化搜索优化
  • 网站建设吉金手指专业13中国营销网站
  • 做销售在哪些网站注册好百度产品
  • dw做汽车网站seo排名工具提升流量
  • 网络培训学校排名奉化seo页面优化外包
  • vps除了做网站还能做什么晨阳seo服务
  • seo网站建设优化什么意思网络营销与直播电商专业就业前景
  • 工程建设企业网站网站关键词优化应该怎么做
  • 修复wordpress青岛网站优化
  • 敦煌网站做外贸怎样网页推广怎么做的
  • 南京网站建设优化今日头条普通版
  • 网站编辑的工作职能有哪些活动营销案例100例
  • 小程序招商加盟平台我是seo关键词
  • wordpress 发帖机镇江抖音seo
  • 网站建设的小结可以发外链的论坛有哪些
  • 网站正常打开速度网店营销与推广策划方案
  • 义乌 网站制作进入百度app
  • 做外围网站赌球红树林seo基础入门免费教程
  • 绿色风格网站seo排名赚钱
  • 南宁企业免费建站百度推广营销怎么做
  • 建立个人网站的成本短视频seo营销系统
  • 深圳公司名称大全网站结构优化的内容和方法
  • 安康市代驾公司上海网站关键词排名优化报价
  • 怎么在网站上建设投票统计在线培训系统app