class Model { constructor() { this.GetModelList({}); this.newModelList = [] } async GetModelList() { var res = await modelService.Model(); console.log(res); var hot_models = res.hot_models; var newest = res.newest; this.newModelList = [...hot_models, ...newest] this.RenderModelItem(hot_models, '.hot_models') this.RenderModelItem(newest, '.newest') } RenderModelItem(data, className) { if (className == ".hot_models") { $(`${className} .title`).text('热门模特') } else { $(`${className} .title`).text('最新模特') } data.forEach(v => { $(`${className} .model_list`).append( `
${v.title} ${ v.total.length == 0 ? '' : `${v.total}` }

${v.title}

` ) this.BindItemClick(); }); } BindItemClick() { var Item = document.querySelectorAll(".item"); Item.forEach((v,i)=>{ v.onclick = () => { location.href = `model_info.html?id=${this.newModelList[i].id}&t=${this.newModelList[i].title}` } }) } } new Model();