代码内容
function() {return {// 组件初始化init: function (options) {this._super.apply(this, arguments);let newlistId = 'a164793834068171';const imgUrl = './attach/imgs/xuanzhong.png';const templ = `<style id=${newlistId}_click_bgc_style>#${newlistId} .nl-row .nl-col.newList_click_bgc {background: url(${imgUrl});background-size: 100% 100%;background-repeat: no-repeat;}</style>`;$('body').prepend(templ);},// 容器内所有组件加载完成allChildrenLoaded: function () {},componentsRendered: function () {let newlistId = 'a164793834068171';$('#' + newlistId).find('.nl-col').eq(0).addClass('newList_click_bgc')$('#' + newlistId).parent().on('click', '.nl-col', (e) => {$(`#${newlistId} .newList_click_bgc`).removeClass('newList_click_bgc');$(e.currentTarget).addClass('newList_click_bgc');});}};}
使用说明
1、newlistId 更改id 为现场使用的id<br />2、imgUrl :选中新闻列表出现的选中图片效果
效果说明
进入后,默认选中新闻列表第一条,点击某条,则产生对应的选中效果,其他行取消选中效果;
