HarmonyOS 能否提供多选带首字母分类的demo

HarmonyOS 能否提供多选带首字母分类的demo

HarmonyOS
2024-08-10 11:43:20
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
put_get

示例如下:

/* 
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. 
 */ 
import I18n from '@ohos.i18n'; 
import Intl from '@ohos.intl'; 
import display from '@ohos.display'; 
 
let collator = new Intl.Collator(I18n.System.getSystemLocale(), { 
  usage: 'sort', 
  collation: 'pinyin', 
  caseFirst: 'lower' 
}) 
 
let data1 = '{\"code\":\"0\",\"lstRegionInfo\":[[{\"id\":3510,\"name\":\"北京\"},{\"id\":3511,\"name\":\"安徽\"},{\"id\":3656,\"name\":\"福建\"},{\"id\":3751,\"name\":\"甘肃\"},{\"id\":3853,\"name\":\"广东\"},{\"id\":4035,\"name\":\"广西壮族自治区\"},{\"id\":4158,\"name\":\"贵州\"},{\"id\":4261,\"name\":\"海南\"},{\"id\":4304,\"name\":\"河北\"},{\"id\":4489,\"name\":\"河南\"},{\"id\":4672,\"name\":\"黑龙江\"},{\"id\":4814,\"name\":\"湖北\"},{\"id\":4935,\"name\":\"湖南\"},{\"id\":5073,\"name\":\"吉林\"},{\"id\":5147,\"name\":\"江苏\"},{\"id\":5285,\"name\":\"江西\"},{\"id\":5399,\"name\":\"辽宁\"},{\"id\":5516,\"name\":\"内蒙古自治区\"},{\"id\":5630,\"name\":\"宁夏回族自治区\"},{\"id\":5662,\"name\":\"青海\"},{\"id\":5714,\"name\":\"山东\"},{\"id\":5873,\"name\":\"山西\"},{\"id\":6008,\"name\":\"陕西\"},{\"id\":6126,\"name\":\"上海\"},{\"id\":6147,\"name\":\"四川\"},{\"id\":6349,\"name\":\"天津\"},{\"id\":6370,\"name\":\"西藏自治区\"},{\"id\":6451,\"name\":\"新疆维吾尔自治区\"},{\"id\":6565,\"name\":\"云南\"},{\"id\":6711,\"name\":\"浙江\"},{\"id\":6819,\"name\":\"重庆\"}]],\"lstRegionTree\":[],\"success\":true}'; 
let data2 = '{\"code\":\"0\",\"regionInfos\":[{\"code\":\"0\",\"id\":3530,\"leaf\":false,\"name\":\"安庆\",\"parentId\":3511,\"parentNumberCode\":\"3511!\",\"status\":\"1\"},{\"code\":\"0\",\"id\":3542,\"leaf\":false,\"name\":\"蚌埠\",\"parentId\":3511,\"parentNumberCode\":\"3511!\",\"status\":\"1\"},{\"code\":\"0\",\"id\":3556,\"leaf\":false,\"name\":\"池州\",\"parentId\":3511,\"parentNumberCode\":\"3511!\",\"status\":\"1\"},{\"code\":\"0\",\"id\":3561,\"leaf\":false,\"name\":\"滁州\",\"parentId\":3511,\"parentNumberCode\":\"3511!\",\"status\":\"1\"},{\"code\":\"0\",\"id\":3570,\"leaf\":false,\"name\":\"阜阳\",\"parentId\":3511,\"parentNumberCode\":\"3511!\",\"status\":\"1\"},{\"code\"} 
  @Entry 
  @Component 
  export struct SelectRegionPage { 
    storage: LocalStorage = LocalStorage.getShared() 
    @State alphabetSelected: number = 0 
    @State showPopup: boolean = false 
    public countriesList: Array<Array<string>> = new Array() 
    private indexList: Array<string> = new Array() 
    @State countriesForShow: Array<Array<Array<string>>> = new Array() 
    private indexUtil = I18n.getInstance(I18n.System.getSystemLocale()); 
    private scroller: Scroller = new Scroller() 
    @LocalStorageLink('isPanelCenter') isPanelCenter: boolean = false 
    @LocalStorageLink('isFullPage') isFullPage: boolean = true 
    @LocalStorageLink('isLandScape') isLandScape?: boolean = false; 
    private normalIndexValue: string[] = ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 
      'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] 
    private landScapeIndexValue: string[] = ['#', 'A', '·', 'G', '·', 'M', '·', 'S', '·', 'Z'] 
    @State regionInfo: Array<RegionData> = []; 
    @State regionDataGroupsList: Array<RegionDataGroups> = []; 
    @State selectRegionPath: string = ""; 
    @State selectedRegion: string = ""; 
    @State selectState: boolean = true; 
    private fixedText: string = "请选择"; 
    private noSelect: string = "暂不选择" 
    @State topVp: number = 0; 
 
    getData(name: string) { 
 
      if (name === 'data1') { 
        return JSON.parse(data1) as RegionRequestData; 
      } 
      if (name === 'data2') { 
        return JSON.parse(data2) as RegionRequestData; 
      } 
      if (name === 'data3') { 
        return JSON.parse(data3) as RegionRequestData; 
      } 
 
      return new RegionRequestData(); 
    }
分享
微博
QQ
微信
回复
2024-08-10 17:39:23
相关问题
根据地区名字开头首字母选择地区
648浏览 • 1回复 待解决
HarmonyOS能否提供一个NFC识别的demo
219浏览 • 1回复 待解决
能否提供一个关于SM3加密demo
506浏览 • 1回复 待解决
HarmonyOS 能否提供折线图组件
237浏览 • 1回复 待解决
HarmonyOS提供个路由跳转Demo
273浏览 • 1回复 待解决
HarmonyOS能否提供数据存储样例工程
208浏览 • 1回复 待解决
提供HarmonyOS硬编硬解demo
274浏览 • 1回复 待解决
提供Webview demo有哪些?
31浏览 • 1回复 待解决
HarmonyOS提供自定义组件封装demo
250浏览 • 2回复 待解决
harmonyos开发能否尽快提供map组件啊
6937浏览 • 2回复 待解决
HarmonyOS 能否提供Web样例工程代码?
55浏览 • 1回复 待解决
nginx通过rewrite或proxy_pass能否参数
4173浏览 • 0回复 待解决