1.js在拼接字符的过程中 ,不能以对象的形式上传递参数。
function setData(obj){var imgpath="javascript:this.src='${base}/before/img/1.png'";
var div_show="<div class='achd_baominging'><div class='achd_img'>";
div_show+="<img src='${base}"+obj.image+"' onerror="+imgpath+" onclick='open_data("+obj.id+","+obj.ac_end+")'/></div>";
div_show+="<div class='achd_info'><div class='achd_title'><span class='title_one'>"+obj.title+"</span><br/>";
div_show+="<span class='title_two'>"+obj.summary+"</span></div>";
//判断报名按钮是否显示
if(obj.ac_end=='01'){
div_show+="<div class='achd_btn'><button>报名中</button></div></div>";
}else{
div_show+="<div class='achd_endbtn'><button>已结束</button></div></div>";
}
return div_show;
}
这里的onclick事件的参数传递不能是object类型的数据
2.背景图片更换
$(this).css('background','#1874CD');
3.div 显示仅仅是一行的数据
.title_one{
font-size: 15px;
font-weight: bold;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
font-size: 15px;
font-weight: bold;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}