Showing
1 changed file
with
9 additions
and
9 deletions
| @@ -16,7 +16,7 @@ PersistentStorage.persistProp('indexSettingChannelId', 0); | @@ -16,7 +16,7 @@ PersistentStorage.persistProp('indexSettingChannelId', 0); | ||
| 16 | @Component | 16 | @Component |
| 17 | export struct TopNavigationComponent { | 17 | export struct TopNavigationComponent { |
| 18 | private tabsController: TabsController = new TabsController() | 18 | private tabsController: TabsController = new TabsController() |
| 19 | - @Prop _currentNavIndex: number; | 19 | + @Prop _currentNavIndex?: number; |
| 20 | // 顶导当前选中/焦点下标 | 20 | // 顶导当前选中/焦点下标 |
| 21 | @State currentTopNavSelectedIndex: number = 0; | 21 | @State currentTopNavSelectedIndex: number = 0; |
| 22 | // 顶导数据 | 22 | // 顶导数据 |
| @@ -35,7 +35,6 @@ export struct TopNavigationComponent { | @@ -35,7 +35,6 @@ export struct TopNavigationComponent { | ||
| 35 | // 地方频道列表 | 35 | // 地方频道列表 |
| 36 | @State localChannelList: TopNavDTO[] = [] | 36 | @State localChannelList: TopNavDTO[] = [] |
| 37 | readonly MAX_LINE: number = 1; | 37 | readonly MAX_LINE: number = 1; |
| 38 | - | ||
| 39 | //处理新闻tab顶导频道数据 | 38 | //处理新闻tab顶导频道数据 |
| 40 | topNavListHandle() { | 39 | topNavListHandle() { |
| 41 | let _channelIds: number [] = [] | 40 | let _channelIds: number [] = [] |
| @@ -111,7 +110,9 @@ export struct TopNavigationComponent { | @@ -111,7 +110,9 @@ export struct TopNavigationComponent { | ||
| 111 | AppStorage.set('indexSettingChannelId', this.homeChannelList[0].channelId) | 110 | AppStorage.set('indexSettingChannelId', this.homeChannelList[0].channelId) |
| 112 | } else { | 111 | } else { |
| 113 | let index = this.myChannelList.findIndex(_item => _item.channelId === this.indexSettingChannelId) | 112 | let index = this.myChannelList.findIndex(_item => _item.channelId === this.indexSettingChannelId) |
| 114 | - this.currentTopNavSelectedIndex = index | 113 | + if (index > -1) { |
| 114 | + this.currentTopNavSelectedIndex = index | ||
| 115 | + } | ||
| 115 | } | 116 | } |
| 116 | } | 117 | } |
| 117 | 118 | ||
| @@ -122,8 +123,8 @@ export struct TopNavigationComponent { | @@ -122,8 +123,8 @@ export struct TopNavigationComponent { | ||
| 122 | build() { | 123 | build() { |
| 123 | Column() { | 124 | Column() { |
| 124 | // 顶部搜索、日报logo、早晚报 | 125 | // 顶部搜索、日报logo、早晚报 |
| 125 | - Column(){ | ||
| 126 | - Row(){ | 126 | + Column() { |
| 127 | + Row() { | ||
| 127 | FirstTabTopSearchComponent() | 128 | FirstTabTopSearchComponent() |
| 128 | 129 | ||
| 129 | Image($r('app.media.icon_ren_min_ri_bao')) | 130 | Image($r('app.media.icon_ren_min_ri_bao')) |
| @@ -168,7 +169,8 @@ export struct TopNavigationComponent { | @@ -168,7 +169,8 @@ export struct TopNavigationComponent { | ||
| 168 | }) | 169 | }) |
| 169 | }.width('100%') | 170 | }.width('100%') |
| 170 | .justifyContent(FlexAlign.SpaceBetween) | 171 | .justifyContent(FlexAlign.SpaceBetween) |
| 171 | - }.height('73lpx') | 172 | + } |
| 173 | + .height('73lpx') | ||
| 172 | .width('100%') | 174 | .width('100%') |
| 173 | .justifyContent(FlexAlign.End) | 175 | .justifyContent(FlexAlign.End) |
| 174 | .backgroundColor($r('app.color.white')) | 176 | .backgroundColor($r('app.color.white')) |
| @@ -266,9 +268,7 @@ export struct TopNavigationComponent { | @@ -266,9 +268,7 @@ export struct TopNavigationComponent { | ||
| 266 | 268 | ||
| 267 | aboutToAppear() { | 269 | aboutToAppear() { |
| 268 | //处理新闻tab顶导频道数据 | 270 | //处理新闻tab顶导频道数据 |
| 269 | - if (this._currentNavIndex === 0) { | ||
| 270 | - this.topNavListHandle() | ||
| 271 | - } | 271 | + this.topNavListHandle() |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | aboutToDisappear() { | 274 | aboutToDisappear() { |
-
Please register or login to post a comment