$.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':''' 大佬们我这个刷新页面后,看到如图
没有起作用,请问大佬是哪里的问题
语法问题
怎么去改正呢
这不像小程序里的代码
建议用 ` ` 包裹 字符串部分
我之前用' '包裹了,没有生效
加上双括号试试{{}}
我有加{{}},报错
你这不是小程序的吧,建议模板里面不要做太多复杂的运算,把想要的值先在外面赋值好再传入模板里
问题很深
按照小程序处理已经是成功的,但在这里面就不行了
class="rightonebtn " + (status === '已通过' ? 'aa' : '')
照你这样来没有生效大佬
那给你写完