如何设置重复器项目背景颜色

How to style Repeater item background color ontap?

本文关键字:项目 背景 颜色 何设置 设置      更新时间:2023-09-26

我在Enyo应用程序中有一个项目重复器。在当前设置中,点击重复器项目不会显示过渡或视觉提示,显示它已被点击。

所以我尝试的是设置从ontap事件传入的repeater项目的类。

但是进入Dev工具告诉我属性addClass没有定义:

IncidentTickets.js:653 Uncaught TypeError: Cannot read property 'addClass' of undefined

问题:

如何设置Enyo Repeater项目的背景颜色?

我设置了一个CSS样式的背景色为绿色:

.tapped {
    background: #0CA281;
}

尝试将CSS类添加到传递给onTap事件的repeater项:

tapPopupBundle: function(inSender, inEvent) {
    var item = this.$.repeaterBundle.itemAtIndex(inEvent.index);
    this.item.addClass('tapped');

},

这是中继器类型的定义:

{kind: "Scroller", name: "scrollerBundle",  touch: true, horizontal:"hidden", showing: false, style: "height: 70%", components: [
                {content:"All Apps", style: "font-size: 12px; font-weight: bold; margin-left: 20px; text-decoration:underline;",ontap: 'clearFilters'},
                {kind: "Repeater", name: "repeaterBundle", count: 0, onSetupItem: "setupBundle", ontap: "tapPopupBundle", components: [
                   {tag: "br"},
                   { kind: "FittableColumns",  components: [
                        {name: "repBundle", style: "font-size: 12px; font-weight: bold; margin-left: 20px;"}
                   ]}
                ]},
             ]},

获取传入的item id并调用appLlyStyle在本例中起作用:

item.$.repAppName.applyStyle("background-color", 'rgb(12,162,129)');