js data manipulation problem solving?

segmentfault 2022-08-06 18:38:24 阅读数:795


Excuse me, I can only get the values ​​returned by the background, such as 1001 and the large area, on the interface 1. Now another interface 2 needs me to pass the parameter BUSDA when I am 1001. The following is their line.Correspondence, there are a total of 10 correspondences, I list three below, how to deal with the front end better, except for one if judgment

1001  Region BUSDA1002  Group BUSTU1003  Shop BUSPU

Other Answer 1:

Use the filter function and three paragraphs to judge

Other Answers 2:

Use the object object to store the mapping relationship:

const id2code = {1001: 'BUSDA',1002: 'BUSTU',1003: 'BUSPU',}
版权声明:本文为[segmentfault]所创,转载请带上原文链接,感谢。 https://primo.wiki/2022/218/202208021526430177.html