HarmonyOS 官方或者第三方是否有五级地区选择空间

HarmonyOS
2024-12-23 15:45:59
748浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
shlp

参考示例:

@Observed
class StringArray extends Array<String> {
}

const cityData: string[][] =
  [['辽宁省', '吉林省', '黑龙江省'], ['沈阳市', '大连市', '长春市'], ['东安区', '西安区', '爱民区'],
    ['小镇1', '小镇2', '小镇3'], ['村1', '村2', '村3']]

@Entry
@Component
struct TabsExample6 {
  private controller: TabsController = new TabsController()
  @State titleArray: Array<string> = ['请选择']
  @State arr: Array<StringArray> = [];

  aboutToAppear(): void {
    this.arr.push(['辽宁省', '吉林省', '黑龙江省']);
  }

  build() {
    Column() {
      Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
        ForEach(this.arr, (itemArr: StringArray, index: number) => {
          TabContent() {
            Column() {
              ForEach(itemArr, (item: string) => {
                ListItem() {
                  Row() {
                    Text(item).fontSize(16).width('80%').align(Alignment.Start)
                      .fontColor(this.titleArray[index] === item ? '#007DFF' : '#182431')
                  }
                }
                .width('80%').height(30).onClick(() => {
                  if (this.titleArray[index] != item) {
                    this.titleArray[index] = item;
                    if (index < cityData.length - 1) {
                      this.titleArray.splice(index + 1)
                      this.titleArray.push("请选择")
                      this.arr.splice(index + 1)
                      this.arr.push(cityData[index + 1])

                      setTimeout(() => {
                        this.controller.changeIndex(index + 1)
                      }, 100);
                    }
                  }
                })
              }, (item: string) => item)
            }.height("100%").width("100%")
          }
          .tabBar(this.titleArray[index])
        }, (item: string) => item)
      }
      .vertical(false)
      .scrollable(true)
      .barMode(BarMode.Scrollable)
      .barHeight(80)
      .animationDuration(200)
      .onChange((index: number) => {
        console.info(index.toString())
      })
    }
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
分享
微博
QQ
微信
回复
2024-12-23 17:49:59
相关问题
HarmonyOS 第三方APP跳转
787浏览 • 1回复 待解决
是否支持使用第三方的webview内核
2135浏览 • 1回复 待解决
HarmonyOS 如何启动第三方APP
872浏览 • 1回复 待解决
HarmonyOS如何移植第三方MCU?
10464浏览 • 1回复 待解决
HarmonyOS 使用第三方应用打开
1025浏览 • 1回复 待解决
HarmonyOS 如何加载第三方页面
746浏览 • 1回复 待解决
HarmonyOS 依赖第三方库报错
1022浏览 • 1回复 待解决
第三方js库迁移懂的吗?
4069浏览 • 1回复 待解决
鸿蒙第三方哪些引入的方法?
477浏览 • 1回复 已解决
native交叉编译第三方
1183浏览 • 1回复 待解决
第三方怎么装鸿蒙系统?
7063浏览 • 1回复 待解决
开发第三方SDK如何编译?
14647浏览 • 2回复 待解决
HarmonyOS 引入第三方Har包问题
1031浏览 • 1回复 待解决
HarmonyOS ohpm添加第三方库报错
1271浏览 • 1回复 待解决
HarmonyOS lottie 第三方报错无法使用
1019浏览 • 1回复 待解决
HarmonyOS 如何拉起第三方地图APP
893浏览 • 1回复 待解决
HarmonyOS 编译第三方大数库libgmp
951浏览 • 1回复 待解决
鸿蒙哪些支持的第三方UI框架吗?
4780浏览 • 1回复 待解决
图片剪切的第三方框架
1034浏览 • 1回复 待解决
如何引入自己的“第三方”库
1538浏览 • 1回复 待解决
HarmonyOS支持的第三方库的列表
2432浏览 • 1回复 待解决