You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
前端下拉筛选通常是一个 value 和 code 的对应关系数组,但基于这个数据,也会有其他映射需求,比如从 code 映射到 value,或从 value 映射到 code,甚至 value 和 code 自身的类型也想确定。此时需要考虑的点就比较多,但我们可以抓住一点:信息的来源只有一点,其他只是形式的变换:
// single truthconstindustryOptions=[{name: '电器',code: 1,},{name: '生鲜',code: 2,},{name: '游戏',code: 3,},]asconst;// derivate from toptypeIndustryOptions=typeofindustryOptionstypeIndustryOptionsIndexUnion=keyofIndustryOptions& `${number}`
typeNameMapCode={[indexinIndustryOptionsIndexUnionasIndustryOptions[index]['name']]: IndustryOptions[index]['code']}typeCodeMapName={[indexinIndustryOptionsIndexUnionasIndustryOptions[index]['code']]: IndustryOptions[index]['name']}typeIndustryCode=keyofCodeMapNametypeIndustryName=keyofNameMapCodeconstnameMapCode=industryOptions.reduce((acc,cur)=>({...acc,[cur.name]: cur.code}),{})asNameMapCodeconstcodeMapName=industryOptions.reduce((acc,cur)=>({...acc,[cur.code]: cur.name}),{})asCodeMapName
The text was updated successfully, but these errors were encountered:
前端下拉筛选通常是一个 value 和 code 的对应关系数组,但基于这个数据,也会有其他映射需求,比如从 code 映射到 value,或从 value 映射到 code,甚至 value 和 code 自身的类型也想确定。此时需要考虑的点就比较多,但我们可以抓住一点:信息的来源只有一点,其他只是形式的变换:
The text was updated successfully, but these errors were encountered: