1 line
1.6 KiB
Plaintext
1 line
1.6 KiB
Plaintext
|
{"version":3,"file":"useColPickerData.js","sources":["../../../../src/hooks/useColPickerData.ts"],"sourcesContent":["// 可以将此代码放置于项目src/hooks/useColPickerData.ts中\r\nimport { useCascaderAreaData } from '@vant/area-data'\r\n\r\nexport type CascaderOption = {\r\n text: string\r\n value: string\r\n children?: CascaderOption[]\r\n}\r\n\r\n/**\r\n * 使用'@vant/area-data'作为数据源,构造ColPicker组件的数据\r\n * @returns\r\n */\r\nexport function useColPickerData() {\r\n // '@vant/area-data' 数据源\r\n const colPickerData: CascaderOption[] = useCascaderAreaData()\r\n\r\n // 根据code查找子节点,不传code则返回所有节点\r\n function findChildrenByCode(data: CascaderOption[], code?: string): CascaderOption[] | null {\r\n if (!code) {\r\n return data\r\n }\r\n for (const item of data) {\r\n if (item.value === code) {\r\n return item.children || null\r\n }\r\n if (item.children) {\r\n const childrenResult = findChildrenByCode(item.children, code)\r\n if (childrenResult) {\r\n return childrenResult\r\n }\r\n }\r\n }\r\n return null\r\n }\r\n\r\n return { colPickerData, findChildrenByCode }\r\n}\r\n"],"names":["useCascaderAreaData"],"mappings":";;AAaO,SAAS,mBAAmB;AAEjC,QAAM,gBAAkCA,cAAAA;AAG/B,WAAA,mBAAmB,MAAwB,MAAwC;AAC1F,QAAI,CAAC,MAAM;AACF,aAAA;AAAA,IACT;AACA,eAAW,QAAQ,MAAM;AACnB,UAAA,KAAK,UAAU,MAAM;AACvB,eAAO,KAAK,YAAY;AAAA,MAC1B;AACA,UAAI,KAAK,UAAU;AACjB,cAAM,iBAAiB,mBAAmB,KAAK,UAAU,IAAI;AAC7D,YAAI,gBAAgB;AACX,iBAAA;AAAA,QACT;AAAA,MACF;AAAA,IACF;AACO,WAAA;AAAA,EACT;AAEO,SAAA,EAAE,eAAe;AAC1B;;"}
|