出于样式目的,我需要一个类将变量值作为类名的一部分
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 或其他内容?
最佳答案
假设您有一个 View ,并且想要动态分配类,如下所示
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);
}
});
关于javascript - 在sensha touch中向类添加变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33661355/