在sensha touch中为类添加变量值

Adding variable value to class in sensha touch

本文关键字:添加 变量值 sensha touch      更新时间:2023-09-26

为了样式化的目的,我需要一个类有一个变量值作为类名的一部分

config: {
    cls: 'section cart-item {variable}',
    items: [{
        layout: 'hbox',
        items: [{
            name: 'image',
            cls: 'left',
            flex: 4,
            tpl: [
                '<div style="min-height: 10em"><img src="{thumbnail}" width=100 /></div>
            ].join('')
        }
...

这似乎不起作用。我读到不支持在cls中添加变量。

以下内容太多,无法尝试使用tpl方法。有没有一种方法可以分解所有内容的div,或者添加一个id或其他东西?

假设您有一个视图,并且您想要动态地分配类,这里是这样的

Ext.define('someview.namespace',{
    config: {
        cls: 'section cart-item',
        // here all other code
    },
    initialize: function(){
       this.callParent();
       var cls = 'abc'; // here get your class dynamically.
       this.addCls(cls);
    }
});