Extjs 如何在Sencha Touch中向dataview元素MTAP事件添加CSS类?

Extjs 如何在Sencha Touch中向dataview元素MTAP事件添加CSS类?,extjs,sencha-touch,dataview,Extjs,Sencha Touch,Dataview,我使用for循环从JSON存储区中的数组加载数据,从而创建了dataview列表。因此,CSS应用于整个dataview,而不是单个元素 { xtype: 'dataview', store: 'AnswerStore', flex:8, height: 600, width: '100%', style: 'background-color:gray; padding: 10px;',

我使用for循环从JSON存储区中的数组加载数据,从而创建了dataview列表。因此,CSS应用于整个dataview,而不是单个元素

{
        xtype: 'dataview',
        store: 'AnswerStore',
        flex:8,
        height: 600,
        width: '100%',
        style: 'background-color:gray; padding: 10px;',
        itemTpl: [
        '<tpl for=".">',
            '<tpl for="questionAnswers">',
                '<div>{answer}</div>',
            '</tpl>',
            '</tpl>'
        ],
        onItemTap: function (container, target, index, e) {
            var me = this;
            this.setStyle('color:red');
        }
{
xtype:“数据视图”,
商店:“AnswerStore”,
弹性:8,
身高:600,
宽度:“100%”,
样式:“背景色:灰色;填充:10px;”,
第三方物流:[
'',
'',
“{答案}”,
'',
''
],
onItemTap:函数(容器、目标、索引、e){
var me=这个;
这个.setStyle('color:red');
}

要获得此输出,请创建css类,并将其作为pressedCls配置提供给列表。
如果要覆盖选定的样式,请将其作为selectedCls配置提供给列表。

在您的OnItemAP中,新样式应应用于
目标对象(即已点击的项)。此外,非常重要的是,OnItemAP的参数需要作为
函数(容器、索引、目标、e)
重新排序

以下是MTAP的整个
功能:

onItemTap: function(container, index, target) {
    target.setStyle({color: 'red'});
}  
我有一把小提琴,如果你想看它的演奏: