Extjs中Ext.Componet.ref属性无效的原因
官方例子中关于ref属性的应用:
1 var grid4 = new Ext.grid.GridPanel({ 2 /*.....此处省略其他代码.......*/ 3 // inline toolbars 4 tbar:[{ 5 text:'Add Something', 6 tooltip:'Add a new row', 7 iconCls:'add' 8 }, '-', { 9 text:'Options', 10 tooltip:'Blah blah blah blaht', 11 iconCls:'option' 12 },'-',{ 13 text:'Remove Something', 14 tooltip:'Remove the selected item', 15 iconCls:'remove', 16 17 // Place a reference in the GridPanel 18 ref: '../removeButton', 19 disabled: true 20 }] 21 /*.....此处省略其他代码.......*/ 22 });
此时可在有效范围内用表达式"grid4.removeButton"对该按钮进行引用,但如果代码从配置式改为new Ext.Toolbar()方式,则ref引用会失效,这是一个很大的陷阱,而官方文档中并无相关说明。
浙公网安备 33010602011771号