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
相关问题
HarmonyOS 提取汉字首字母
28浏览 • 1回复 待解决
根据地区名字开头首字母选择地区
739浏览 • 1回复 待解决
HarmonyOS 能否提供登录界面样例demo
225浏览 • 1回复 待解决
HarmonyOS能否提供一个NFC识别的demo
407浏览 • 1回复 待解决
能否提供一个关于SM3加密demo
685浏览 • 1回复 待解决
HarmonyOS 能否提供脚本打包
69浏览 • 1回复 待解决
HarmonyOS 希望提供napi版音频采集demo
214浏览 • 1回复 待解决
HarmonyOS 能否提供折线图组件
467浏览 • 1回复 待解决
提供Webview demo有哪些?
211浏览 • 1回复 待解决
HarmonyOS提供个路由跳转Demo
391浏览 • 1回复 待解决
拉起相机或者图库demo提供
247浏览 • 1回复 待解决
能否提供图片预览官方实现?
276浏览 • 1回复 待解决
HarmonyOS能否提供数据存储样例工程
360浏览 • 1回复 待解决
提供HarmonyOS硬编硬解demo
439浏览 • 1回复 待解决