中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

網(wǎng)站地圖對seo的影響品牌營銷策劃與管理

網(wǎng)站地圖對seo的影響,品牌營銷策劃與管理,怎么做自己的代刷網(wǎng)站,個人可以做醫(yī)療信息網(wǎng)站嗎【HarmonyOS】Observed和ObjectLink嵌套對象屬性更改UI不刷新問題 一、問題背景 使用了Observed和ObjectLink,修改嵌套對象的屬性,UI還是不刷新,常見的問題有以下三種形式: 1.多級嵌套,嵌套對象的類并沒有添加Observ…

【HarmonyOS】@Observed和@ObjectLink嵌套對象屬性更改UI不刷新問題

一、問題背景

使用了@Observed和@ObjectLink,修改嵌套對象的屬性,UI還是不刷新,常見的問題有以下三種形式:
1.多級嵌套,嵌套對象的類并沒有添加@Observed進行監(jiān)聽
2.多級嵌套,嵌套對象的View組件沒有抽離出來,添加@ObjectLink進行該級對象的監(jiān)聽綁定
3.嵌套對象,并沒有new出來創(chuàng)建,直接賦值沒有創(chuàng)建對象的過程,無法激活Observed監(jiān)聽

二、代碼舉例

以代碼示例舉例:
1.創(chuàng)建了接口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.添加測試數(shù)據(jù),渲染列表,單元格數(shù)據(jù)基本類型結(jié)構(gòu)為TestInfo。



struct TestPage { mTestDataArr: TestInfo[] = [new TestInfo('測試數(shù)據(jù)1', [{content: '單元數(shù)據(jù)1',isClicked: false}, {content: '單元數(shù)據(jù)1',isClicked: false}]),new TestInfo('測試數(shù)據(jù)2', [{content: '單元數(shù)據(jù)1',isClicked: false}, {content: '單元數(shù)據(jù)1',isClicked: false}]),new TestInfo('測試數(shù)據(jù)3', [{content: '單元數(shù)據(jù)1',isClicked: false}, {content: '單元數(shù)據(jù)1',isClicked: false}]),]build() {Column() {ForEach(this.mTestDataArr, (item: TestInfoInterFace) => {ChildView({mTestInfo: item})})}.width('100%').height('100%')}
}

3.抽離嵌套組件ChildView ,綁定雙向監(jiān)聽。



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()}}
}

渲染界面后的效果為:
在這里插入圖片描述
此時我們點擊單元數(shù)據(jù)1或者2,去修改isClicked選中狀態(tài),并不會刷新UI,整個代碼有以上總結(jié)的三個問題:
1.TestItem 多級嵌套,嵌套對象的類并沒有添加@Observed進行監(jiān)聽

2.ChildView 多級嵌套了一個層級,直接就進行了循環(huán)渲染,其嵌套對象的View組件沒有抽離出來,添加@ObjectLink進行該級對象的監(jiān)聽綁定

3.mTestDataArr嵌套對象中的TestItem并沒有new出來創(chuàng)建,是通過花括號直接賦值沒有創(chuàng)建對象的過程,無法激活Observed監(jiān)聽

三、完整DEMO示例:

interface TestInfoInterFace {name: string;items: TestItem[];
}// TODO 問題1:多層級時,需要逐個層級進行類監(jiān)聽

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 每個被設(shè)置Observed的對象,需要new出來創(chuàng)建,才能激活監(jiān)聽,花括號的形式賦值,并不會激活監(jiān)聽。 mTestDataArr: TestInfo[] = [new TestInfo('測試數(shù)據(jù)1', [new TestItem('單元數(shù)據(jù)1', false), new TestItem('單元數(shù)據(jù)2', false)]),new TestInfo('測試數(shù)據(jù)2', [new TestItem('單元數(shù)據(jù)1', false), new TestItem('單元數(shù)據(jù)2', false)]),new TestInfo('測試數(shù)據(jù)3', [new TestItem('單元數(shù)據(jù)1', false), new TestItem('單元數(shù)據(jù)2', false)]),//   new TestInfo('測試數(shù)據(jù)1', [{//     content: '單元數(shù)據(jù)1',//     isClicked: false//   }, {//     content: '單元數(shù)據(jù)1',//     isClicked: false//   }]),//   new TestInfo('測試數(shù)據(jù)2', [{//     content: '單元數(shù)據(jù)1',//     isClicked: false//   }, {//     content: '單元數(shù)據(jù)1',//     isClicked: false//   }]),//   new TestInfo('測試數(shù)據(jù)3', [{//     content: '單元數(shù)據(jù)1',//     isClicked: false//   }, {//     content: '單元數(shù)據(jù)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 多層級時,需要逐個層級進行剝離,創(chuàng)建子組件和綁定雙向監(jiān)聽。// 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://www.risenshineclean.com/news/30435.html

相關(guān)文章:

  • 做pc端網(wǎng)站平臺今日頭條熱點新聞
  • 建筑網(wǎng)片的用途seo優(yōu)化工具
  • 沌口網(wǎng)站建設(shè)淘寶seo搜索排名優(yōu)化
  • wordpress主頁底端添加圖常州網(wǎng)站seo
  • 公司網(wǎng)站可以自己做河南關(guān)鍵詞排名顧問
  • 網(wǎng)站建設(shè)文案有趣網(wǎng)站關(guān)鍵詞快速排名服務(wù)
  • 網(wǎng)站備案最快多久seo學(xué)院培訓(xùn)班
  • 上傳網(wǎng)站怎么安裝寧德市蕉城區(qū)疫情
  • wordpress隱藏回復(fù)插件seo做關(guān)鍵詞怎么收費的
  • 網(wǎng)站發(fā)外鏈中山seo排名
  • 四川移動網(wǎng)站建設(shè)怎樣做推廣是免費的
  • 網(wǎng)頁界面設(shè)計系統(tǒng)seo描述是什么
  • 網(wǎng)頁設(shè)計軟件adobe鄭州seo技術(shù)顧問
  • ui設(shè)計培訓(xùn)需要多少費用百度關(guān)鍵詞搜索優(yōu)化
  • 織夢網(wǎng)站動態(tài)網(wǎng)站建設(shè)推廣優(yōu)化
  • 老鷹畫室網(wǎng)站哪家做的b站視頻怎么快速推廣
  • 建網(wǎng)站怎么分類亞馬遜關(guān)鍵詞搜索器
  • 吳江做網(wǎng)站建站abc官方網(wǎng)站
  • 佛山外貿(mào)型網(wǎng)站如何做好一個網(wǎng)站
  • 網(wǎng)站知識介紹杭州網(wǎng)站建設(shè)
  • 百度網(wǎng)站托管網(wǎng)站統(tǒng)計哪個好用
  • 淘寶上買衣服的網(wǎng)站湖南企業(yè)seo優(yōu)化首選
  • 手機端網(wǎng)站做app阿里巴巴怎么優(yōu)化關(guān)鍵詞排名
  • 中小企業(yè)融資服務(wù)平臺專業(yè)seo整站優(yōu)化
  • 網(wǎng)站的優(yōu)化承諾上海最新新聞熱點事件
  • 泰州網(wǎng)站建設(shè)方案視頻運營管理平臺
  • 小公司怎么做免費網(wǎng)站西安網(wǎng)站seo優(yōu)化公司
  • 鄭州市建設(shè)廳網(wǎng)站網(wǎng)絡(luò)營銷的現(xiàn)狀
  • 群暉 docker wordpress廣州百度推廣優(yōu)化排名
  • l建設(shè)銀行網(wǎng)站深圳最新消息