给每一个渲染出来的结构添加点击事件,并传参
volunteer: function(id) {
window.location.href = DOMAIN+"/Cloud/Module/Information/Show/Show.html?id="+id;
},
// 志愿风采
elegantArt: function() {
$.ajax({
url: API + '/front/information/getList?currentPage=1&type=-1&informationCategoryId=64016df6772cf17748caf276',
type: 'GET',
success: function(data) {
let html = ''
$.each(data.data, function (i, item) {
html += '<div class="artContent" οnclick="index.volunteer(`'+ item.id +'`)">\n' +
' <img src="' + IMGPATH + item.imagePath + '">\n' +
' <p class="art_titlep">' + item.title.replace(/(.{18})(.*)?/g, '$1...') + '</p>\n' +
' </div>\n' +
' </div>'
})
$("#artList").html(html)
}
})
}
最外层需要再拼接一个多行串,把它变成字符串才可以识别