Ext中关于 Ext.extend

beikez 2010-07-10 06:02:34
在学习Ext.extend方法时遇到些疑问,请教一下~~
谢谢额!!



Ext.MyWindow = Ext.extend(Ext.Window, {
width: 300,
height: 200,
helloWorld: function () {
Ext.msg.alert("Hello world!");
},
buttons: [
{ text: "调用 helloWorld 方法", handler: function () {

// 这样?
// Ext.MyWindow.helloWorld() ?

} }
]
});


Ext.onReady(function () {
var win = new Ext.MyWindow();
win.show();

});
...全文
68 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
beikez 2011-01-17
  • 打赏
  • 举报
回复
你们呀,自己都没试过..... 总是想当然的~
        Ext.MyWindow = Ext.extend(Ext.Window, {
initComponent: function () {
var btn1 = new Ext.Button({ text: 'hello', handler: function () { this.helloWorld(); }, scope: this });
this.buttons = [btn1];
Ext.MyWindow.superclass.initComponent.call(this);
},
width: 300,
height: 200,
helloWorld: function () {
alert("Hello world!");
}
});


Ext.onReady(function () {
var win = new Ext.MyWindow();
win.show();

});

hnwlh 2010-07-28
  • 打赏
  • 举报
回复
text: "调用 helloWorld 方法", handler:helloWorld
肖义崇 2010-07-28
  • 打赏
  • 举报
回复
this.helloWorld,scope:this
may_beyond 2010-07-28
  • 打赏
  • 举报
回复
麻烦不?
直接 handler:this.helloWorld,
zoujp_xyz 2010-07-11
  • 打赏
  • 举报
回复
也可以是this.helloWorld();

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧