我想在绑定后更改css类。在ExtJS5中有可能吗?
我补充了一些评论。小提琴:https://fiddle.sencha.com/#fiddle/olc
发布于 2015-06-13 18:44:21
您的代码中有几个问题:
iconCls:'{rating}'[0] )之后添加索引--这在语法上是不正确的。rating公式,就必须运行get函数- get()。试试这段代码
Ext.define('Fiddle.view.FooModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.fiddle-foo',
data: {
val: 1
},
formulas: {
rating: function(get) {
get();
return 'hello-world';
}
}
});
Ext.define('Fiddle.view.Foo', {
extend: 'Ext.panel.Panel',
xtype: 'fiddle-foo',
viewModel: {
type:'fiddle-foo'
},
layout: 'hbox',
height: 50,
width: 250,
items: [{
xtype: 'button',
text: 'rating 1',
bind:{
iconCls:'{rating}'
}
}, {
xtype: 'button',
text: 'rating 2',
bind:{
iconCls:'{rating}'
}
}, {
xtype: 'button',
text: 'rating 3',
bind:{
iconCls:'{rating}'
}
}]
});
Ext.application({
name: 'Fiddle',
launch: function() {
new Fiddle.view.Foo({
renderTo: document.body,
width: 400,
height: 400,
title: 'Test'
});
}
});https://stackoverflow.com/questions/30820939
复制相似问题