三目运算没有起到作用
发布于 5 年前 作者 speng 4238 次浏览 来自 问答
$.ajax({
        type:"GET",
        url:"https://www.ajsdhfd.cn/ecard/shops",
        async:true,
        data:{
            offset:1,limit:100,
        },
        dataType:"json",
        success:function(res){
            console.log(res)
            var shoplist=res.data.records
            console.log(shoplist)
            for(var i=0;i<shoplist.length;i++){
                if(shoplist[i].status=="OPEN"){
                    shoplist[i].status="已通过"
                    $(this).addClass("aaa")
                    shoplist[i].className="aaa";
                }else if(shoplist[i].status=="AUDIT"){
                    shoplist[i].status="未通过"
                     
//                  shoplist[i].className="aaa";
                }
                var tr="<tr>\n"+
                "   <td>2018/8/8 11:34</td>\n"+
                "   <td>\n"+
                "   <img src=\""+shoplist[i].firstImageUrl+"\"/>\n"+
                "   </td>\n"+
                "   <td>"+shoplist[i].businessName+" </td>\n"+
                "   <td>"+shoplist[i].name+"</td>\n"+
                "   <td>"+shoplist[i].city+""+shoplist[i].district+"</td>\n"+
                "   <td>"+shoplist[i].address+"</td>\n"+
                "   <td>"+shoplist[i].phone+"</td>\n"+
                "   <td id=\""+shoplist[i].id+"\">"+shoplist[i].rate+"%</td>\n"+
                "   <td>\n"+
                "   <p class=\"rightonep\" data-shopid=\""+shoplist[i].id+"\" data-busid=\""+shoplist[i].businessId+"\" onclick=\"rightonecompiler(this.id)\">编辑佣金</p>\n"+
                "   <span class=\"rightonebtn '"+shoplist[i].status+"=='已通过'?'aaa':'''\" id=\"rightonepid\" data-busid=\""+shoplist[i].businessId+"\" data-shopid=\""+shoplist[i].id+"\"  >"+shoplist[i].status+"</span>\n"+
                "   </td>\n"+
                "</tr>";
                $("#rightonemaddle").append(tr);
            }                                  
        }
    })

‘"+shoplist[i].status+"==‘已通过’?‘aaa’:’’’ 大佬们我这个刷新页面后,看到如图

没有起作用,请问大佬是哪里的问题

4 回复

这不像小程序里的代码

建议用     `  `         包裹 字符串部分

加上双括号试试{{}}

问题很深

回到顶部