終於知道ExtJS裏面的scope的作用了

在ExtJS裏面, 由於是組件化開發,涉及到作用域的時候怎麼辦?

比如一個splitbutton,在一個大panel裏面,

點擊時它的事件處理裏面,如果不寫scope,那麼傳到onPrintPDF函數裏的對象就是這個按鈕本身,

寫了scope,就是panel

let me = this;  

let t_print_menu = {
          xtype: 'splitbutton',
          text: report.Message.print,
          iconCls: "PSI-button-print",
          disabled: t_print_disabled,
          handler: me.onPrintPDF,
          scope: me,
          menu: t_print_tpl_menu,
        }
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章