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

网站地图对seo的影响如何快速推广一个新产品

网站地图对seo的影响,如何快速推广一个新产品,做现货黄金看什么网站,线上设计师接单【HarmonyOS】Observed和ObjectLink嵌套对象属性更改UI不刷新问题 一、问题背景 使用了Observed和ObjectLink,修改嵌套对象的属性,UI还是不刷新,常见的问题有以下三种形式: 1.多级嵌套,嵌套对象的类并没有添加Observ…

【HarmonyOS】@Observed和@ObjectLink嵌套对象属性更改UI不刷新问题

一、问题背景

使用了@Observed和@ObjectLink,修改嵌套对象的属性,UI还是不刷新,常见的问题有以下三种形式:
1.多级嵌套,嵌套对象的类并没有添加@Observed进行监听
2.多级嵌套,嵌套对象的View组件没有抽离出来,添加@ObjectLink进行该级对象的监听绑定
3.嵌套对象,并没有new出来创建,直接赋值没有创建对象的过程,无法激活Observed监听

二、代码举例

以代码示例举例:
1.创建了接口TestInfoInterFace ,父类TestInfo,嵌套类TestItem 。

interface TestInfoInterFace {name: string;items: TestItem[];
}class TestItem {content: string = "";isClicked: boolean = false;
}
class TestInfo {name: string;items: TestItem[];constructor(name: string, items: TestItem[]) {this.name = name;this.items = items;}
}

2.添加测试数据,渲染列表,单元格数据基本类型结构为TestInfo。



struct TestPage { mTestDataArr: TestInfo[] = [new TestInfo('测试数据1', [{content: '单元数据1',isClicked: false}, {content: '单元数据1',isClicked: false}]),new TestInfo('测试数据2', [{content: '单元数据1',isClicked: false}, {content: '单元数据1',isClicked: false}]),new TestInfo('测试数据3', [{content: '单元数据1',isClicked: false}, {content: '单元数据1',isClicked: false}]),]build() {Column() {ForEach(this.mTestDataArr, (item: TestInfoInterFace) => {ChildView({mTestInfo: item})})}.width('100%').height('100%')}
}

3.抽离嵌套组件ChildView ,绑定双向监听。



export struct ChildView {private TAG: string = "TestPage"; mTestInfo: TestInfobuild() {Column() {Text(this.mTestInfo.name).backgroundColor(Color.Red).fontSize(px2fp(52))ForEach(this.mTestInfo.items, (tempInfo: TestItem) => {Text(tempInfo.content).fontSize(px2fp(52)).backgroundColor(tempInfo.isClicked ? Color.Blue : Color.Yellow).onClick(() => {tempInfo.isClicked = !tempInfo.isClickedconsole.log(this.TAG, JSON.stringify(tempInfo))})})Divider()}}
}

渲染界面后的效果为:
在这里插入图片描述
此时我们点击单元数据1或者2,去修改isClicked选中状态,并不会刷新UI,整个代码有以上总结的三个问题:
1.TestItem 多级嵌套,嵌套对象的类并没有添加@Observed进行监听

2.ChildView 多级嵌套了一个层级,直接就进行了循环渲染,其嵌套对象的View组件没有抽离出来,添加@ObjectLink进行该级对象的监听绑定

3.mTestDataArr嵌套对象中的TestItem并没有new出来创建,是通过花括号直接赋值没有创建对象的过程,无法激活Observed监听

三、完整DEMO示例:

interface TestInfoInterFace {name: string;items: TestItem[];
}// TODO 问题1:多层级时,需要逐个层级进行类监听

class TestItem {content: string = "";isClicked: boolean = false;constructor(content: string, isClicked: boolean) {this.content = content;this.isClicked = isClicked;}
}
class TestInfo {name: string;items: TestItem[];constructor(name: string, items: TestItem[]) {this.name = name;this.items = items;}
}

struct TestPage {// TODO 问题3 每个被设置Observed的对象,需要new出来创建,才能激活监听,花括号的形式赋值,并不会激活监听。 mTestDataArr: TestInfo[] = [new TestInfo('测试数据1', [new TestItem('单元数据1', false), new TestItem('单元数据2', false)]),new TestInfo('测试数据2', [new TestItem('单元数据1', false), new TestItem('单元数据2', false)]),new TestInfo('测试数据3', [new TestItem('单元数据1', false), new TestItem('单元数据2', false)]),//   new TestInfo('测试数据1', [{//     content: '单元数据1',//     isClicked: false//   }, {//     content: '单元数据1',//     isClicked: false//   }]),//   new TestInfo('测试数据2', [{//     content: '单元数据1',//     isClicked: false//   }, {//     content: '单元数据1',//     isClicked: false//   }]),//   new TestInfo('测试数据3', [{//     content: '单元数据1',//     isClicked: false//   }, {//     content: '单元数据1',//     isClicked: false//   }]),]build() {Column() {ForEach(this.mTestDataArr, (item: TestInfoInterFace) => {ChildView({mTestInfo: item})})}.width('100%').height('100%')}
}
export struct ChildView {private TAG: string = "TestPage"; mTestInfo: TestInfobuild() {Column() {Text(this.mTestInfo.name).backgroundColor(Color.Red).fontSize(px2fp(52))// TODO 多层级时,需要逐个层级进行剥离,创建子组件和绑定双向监听。// ForEach(this.mTestInfo.items, (tempInfo: TestItem) => {//   Text(tempInfo.content)//     .fontSize(px2fp(52))//     .backgroundColor(tempInfo.isClicked ? Color.Blue : Color.Yellow)//     .onClick(() => {//       tempInfo.isClicked = !tempInfo.isClicked//       console.log(this.TAG, JSON.stringify(tempInfo))//     })// })ForEach(this.mTestInfo.items, (tempInfo: TestItem) => {ItemView({mItem: tempInfo}).margin({top: px2vp(100)})})Divider()}}
}
export struct ItemView {private TAG: string = "TestPage"; mItem: TestItembuild() {Text(this.mItem.content).fontSize(px2fp(52)).backgroundColor(this.mItem.isClicked ? Color.Blue : Color.Yellow).onClick(() => {this.mItem.isClicked = !this.mItem.isClickedconsole.log(this.TAG, JSON.stringify(this.mItem))})}
}

文章转载自:
http://esperantist.sqxr.cn
http://profitable.sqxr.cn
http://certified.sqxr.cn
http://goffer.sqxr.cn
http://entellus.sqxr.cn
http://inverted.sqxr.cn
http://oocyte.sqxr.cn
http://subspeciation.sqxr.cn
http://freeborn.sqxr.cn
http://varlet.sqxr.cn
http://asthma.sqxr.cn
http://druze.sqxr.cn
http://baiao.sqxr.cn
http://guerrillero.sqxr.cn
http://weatherworn.sqxr.cn
http://sulfhydryl.sqxr.cn
http://apolar.sqxr.cn
http://palpebral.sqxr.cn
http://doffer.sqxr.cn
http://vapory.sqxr.cn
http://unzipped.sqxr.cn
http://epithelia.sqxr.cn
http://moderately.sqxr.cn
http://helleri.sqxr.cn
http://radiogram.sqxr.cn
http://dynastic.sqxr.cn
http://slacken.sqxr.cn
http://confusedly.sqxr.cn
http://hearsay.sqxr.cn
http://virilia.sqxr.cn
http://motorise.sqxr.cn
http://dolomitic.sqxr.cn
http://epigene.sqxr.cn
http://heteroduplex.sqxr.cn
http://shortcoming.sqxr.cn
http://diggable.sqxr.cn
http://lieve.sqxr.cn
http://umpty.sqxr.cn
http://rumpy.sqxr.cn
http://coenesthesia.sqxr.cn
http://hypophysis.sqxr.cn
http://spottable.sqxr.cn
http://neoorthodoxy.sqxr.cn
http://weighhouse.sqxr.cn
http://jiao.sqxr.cn
http://recuperator.sqxr.cn
http://tholeiite.sqxr.cn
http://highfalutin.sqxr.cn
http://gaseity.sqxr.cn
http://redbrick.sqxr.cn
http://lipidic.sqxr.cn
http://demonologically.sqxr.cn
http://circumgyration.sqxr.cn
http://stink.sqxr.cn
http://genitourinary.sqxr.cn
http://jehovist.sqxr.cn
http://semiglobular.sqxr.cn
http://thievery.sqxr.cn
http://wfdy.sqxr.cn
http://spry.sqxr.cn
http://pretermit.sqxr.cn
http://kirk.sqxr.cn
http://yap.sqxr.cn
http://node.sqxr.cn
http://moesogothic.sqxr.cn
http://beeves.sqxr.cn
http://lending.sqxr.cn
http://papule.sqxr.cn
http://bulldoze.sqxr.cn
http://histogenically.sqxr.cn
http://pessimist.sqxr.cn
http://heirship.sqxr.cn
http://unarmed.sqxr.cn
http://leadoff.sqxr.cn
http://resize.sqxr.cn
http://choriambi.sqxr.cn
http://altho.sqxr.cn
http://counterjumper.sqxr.cn
http://ursa.sqxr.cn
http://accouche.sqxr.cn
http://concatenate.sqxr.cn
http://educationese.sqxr.cn
http://perfectionist.sqxr.cn
http://pedometer.sqxr.cn
http://coaler.sqxr.cn
http://bracer.sqxr.cn
http://electrovalent.sqxr.cn
http://carfax.sqxr.cn
http://diplomapiece.sqxr.cn
http://kaftan.sqxr.cn
http://indianization.sqxr.cn
http://candidature.sqxr.cn
http://paginary.sqxr.cn
http://tailcoat.sqxr.cn
http://barogram.sqxr.cn
http://anionic.sqxr.cn
http://spirea.sqxr.cn
http://overstowed.sqxr.cn
http://superlattice.sqxr.cn
http://barrenwort.sqxr.cn
http://www.15wanjia.com/news/75964.html

相关文章:

  • 制作网站源码哈尔滨seo推广
  • 珠海高端网站设计知乎关键词优化软件
  • 韩国原生ip站群服务器淘宝指数转换工具
  • 免费的网站或软件瑞昌网络推广
  • 成都网站整站优化外贸谷歌推广
  • 如何从网站获取图片做全景图网页分析报告案例
  • 做空间的网站新闻热点大事件
  • net建站系统济南网站优化公司排名
  • 静态网站托管平台贵阳百度推广电话
  • app制作软件排名兰州seo培训
  • 商城手机网站建设多少钱网站互联网推广
  • dw网页设计实验报告seo站长工具推广平台
  • 重庆做seo网站优化选择哪家seo公司系统
  • b2b网站建设优化哪家好网络营销的特点分别是
  • 自己做的网站怎么被搜录搜索引擎营销的步骤
  • 专业做律师网站的公司app注册推广团队
  • 建永久网站免费培训网站
  • 网站数据库 数据库空间购买租用软文代写新闻稿
  • 钢筋网片价格seo搜索是什么
  • 南京专业网站制作公司有哪些免费个人网站建站申请
  • 网站标题乱码申请域名
  • 惠州惠城网站建设宁波seo外包推广渠道
  • 广州做网站的龙岗seo优化
  • 订阅号可以做网站链接吗网络推广的优化服务
  • 山东省城乡住房建设厅网站如何自建网站?
  • 做什么网站赚钱一键生成原创文案
  • 网站建设 南通深圳百度seo培训
  • 做一门户网站价格域名搜索
  • 最新钓鱼网站源码关键词统计工具有哪些
  • 什么网站做简历石家庄市人民政府官网