ExtJs 继承 和 插件 示例

 1 Ext.ns('Ext.ux');
 2 
 3 function btn(){
 4     alert(this.id);
 5 };
 6 var panel_plugs = {//定义插件
 7     init : function(panel){
 8         panel.width = 600;
 9         panel.height = 300;
10         panel.title = '测试';
11         panel.tools = [{id:"maximize ",handler:btn},{id:"minimize ",handler:btn},{id:"close ",handler:btn}];
12     }
13 };

方法一:

 1 Ext.MyPanel = function(){
 2             //Ext.MyPanel.superclass.initComponent.call(this);
 3             Ext.MyPanel.superclass.constructor.call(this,{
 4                 id : 'div_ext',
 5                 title : 'ceshi',
 6                 width : 600,
 7                 height : 300,
 8                 renderTo : 'div1',
 9                 tbar : [{text:"1"},{text:"2"},{text:"3"}]
10             })
11 };
12 Ext.extend(Ext.MyPanel,Ext.Panel,{
13         plugins : panel_plugs
14 });

方法二:

 1 Ext.MyPanel = Ext.extend(Ext.Panel,{

 2         id : 'div_ext',
 3         title : 'ceshi',
 4         width : 600,
 5         height : 300,
 6         renderTo : 'div1',
 7         tbar : [{text:"1"},{text:"2"},{text:"3"}],
 8 
 9         plugins : panel_plugs
10 // constructor : function(){ 11 // Ext.MyPanel.superclass.constructor.call(this); 12 // }, 13 // initComponent : function(){ 14 // Ext.MyPanel.superclass.initComponent.call(this); 15 // } 16 });

运行代码:

1 Ext.reg('mypanel',Ext.MyPanel);
2 
3 Ext.onReady(function(){
4     new Ext.MyPanel();
5 })

结果图:

转载于:https://www.cnblogs.com/yhc20091116/p/4630287.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值