0
使用ExtJS,如何防止組件根據條件呈現到DOM中?該代碼可能會是這樣的(我使用煎茶建築師生成代碼,所以我不是100%熟悉語法)如何根據條件放棄組件渲染
Ext.define('MyApp.view.MyButton', {
extend: 'Ext.button.Button',
text: 'MyButton',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
listeners: {
beforerender: {
fn: me.onButtonBeforeRender,
scope: me
}
}
});
me.callParent(arguments);
},
onButtonBeforeRender: function(component, eOpts) {
if (MyCondition) {
// all good, go on with rendering this component
}
else {
// no good, abort, this component should not be rendered
}
}
});