通过参数匹配相应内容

通过名字传定义参进行匹配

if(obj.if_lianyou=='0'){
                       var  city = [
                        {name:'北京',logo:'mlw_bj_20200630.png'},
                        {name:'福州',logo:'mlw_fz_20200630.png'},
                        {name:'成都',logo:'mlw_cd_20200630.png'},
                        {name:'重庆',logo:'mlw_cq_20200630.png'},
                        {name:'长沙',logo:'mlw_cs_20200630.png'},
                        {name:'合肥',logo:'mlw_hf_20200630.png'},
                        {name:'济南',logo:'mlw_jn_20200630.png'},
                        {name:'昆明',logo:'mlw_km_20200630.png'},
                        {name:'宁波',logo:'mlw_nb_20200630.png'},
                        {name:'南昌',logo:'mlw_nc_20200630.png'},
                        {name:'南京',logo:'mlw_nj_20200630.png'},
                        {name:'南宁',logo:'mlw_nn_20200630.png'},
                        {name:'青岛',logo:'mlw_qd_20200630.png'},
                        {name:'苏州',logo:'mlw_sz_20200630.png'},
                        {name:'天津',logo:'mlw_tj_20200630.png'},
                        {name:'西安',logo:'mlw_xa_20200630.png'},
                        ]
                        //obj.company.name  这个是我的接口获取到的参数
                       let citys = city.filter(
                           function (item) {
                               return item.name == obj.company.name
                           }
                        )[0]

或者                  for(var i=0;i<city.length;i++){
                           if(city[i].name==obj.company_name){
                                citys=city[i]
                           }
                       }

                        $('#signet img').attr('src','http://xeme.oss-cn-shanghai.aliyuncs.com/iron/gongzhang/' + citys.logo);
                    }
						//obj.if_lianyou  通过判断展示不同值的情况数据
                    if(obj.if_lianyou == '1'){
                      var imgUrl ='img_lianyou@3x.png' 
                      $('#signet img').attr('src','/images/electronic/' + imgUrl);
                    }
展开阅读全文
©️2020 CSDN 皮肤主题: 游动-白 设计师: 上身试试 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值