js遍历map匹配数据和js遍历数组匹配map数据

var __LocalDataCities = {
  list: {
    "010": ["北京", "BEIJING"],
    "010010010": ["东城区", "DONGCHENG"],
    "010010020": ["西城区", "XICHENG"],
    "010010030": ["朝阳区", "CHAOYANG"],
    "010010050": ["海淀区", "HAIDIAN"],
    "010010070": ["石景山", "SHIJINGSHAN"],
    "010010080": ["门头沟", "MENTOUGOU"],
    "010010090": ["丰台区", "FENGTAI"],
    "010010100": ["房山区", "FANGSHAN"],
    "010010110": ["大兴区", "DAXING"],
    "010010120": ["通州区", "TONGZHOU"],
    "010010130": ["顺义区", "SHUNYI"],
    "010010140": ["平谷区", "PINGGU"],
    "010010150": ["昌平区", "CHANGPING"],
    "010010160": ["怀柔区", "HUAIROU"],
    "010010170": ["延庆县", "YANQING"],
    "010010180": ["密云县", "MIYUN"],
    "020": ["上海", "SHANGHAI"],
    "020010010": ["浦东新区", "PUDONGXINQU"],
    "300040": ["克拉玛依", "KELAMAYI"],
    "060150": ["盐城", "YANCHENG"],
    "060100": ["无锡", "WUXI"]
}}
//var cityId = "300040";
var cityId = ["300040","060150","060100"]
function addressShow(){
    addressCity = __LocalDataCities.list;
    for(var i in addressCity){
        for(var j=0;j<cityId.length;j++){
            if(i==cityId[j]){
                console.log(addressCity[i][0]);
            }
        }
        //if(i==cityId){
            //console.log(addressCity[i][0]);
        //}
    }
}

 

posted @ 2018-03-21 15:16  知兮  阅读(1078)  评论(0编辑  收藏  举报