@JS 类的声明,和对象的创建
类的创建,实际是创建一个function。使用时要先new
function user(){
//this 相当于 高级语言的public
this.Name = 'uspcat';
this.age = 26;
//var 就相对于高级语言当中的private
var email = "yfc@126.com"
//以下相当于java中的geter
this.getEmail = function(){
return email;
}
}
使用:
var u = new user();
alert(u.getEmail())
方法二:
var person = {
name:'yfc'
,age:26
};
使用
alert(person.name+" "+person['age'])
@原始方法用EXTJS创建一个window
var win = new Ext.window.Window({
width:400,
height:300,
title:'uspcat'
});
win.show();
@
利用一个按钮触发window窗体,了解EXTJS的事件机制
<button id="myb">
Show
</button>
1.得到那个按钮的dom对象
2.为按钮对象添加单击的事件
3.单击的时候调用对象win的show方法
Ext.get("myb").on("click",function(){
win.show();
});
@用EXTJS4.0的create来创建window
1.Ext.create() = Exr.ClassManager.instantiate()
2.alias
var o = {
say : function(){
alert(11111);
}
}
var fn = Ext.Function.alias(o,'say');
//使用
fn();
官方例子:
alias
: String
[]
List of short aliases for class names. Most useful for defining xtypes for widgets
Ext.define('MyApp.CoolPanel', {
extend: 'Ext.panel.Panel',
alias: ['widget.coolpanel'],
title: 'Yeah!'
});
// Using Ext.create
Ext.widget('widget.coolpanel');
// Using the shorthand for widgets and in xtypes
Ext.widget('panel', {
items: [
{xtype: 'coolpanel', html: 'Foo'},
{xtype: 'coolpanel', html: 'Bar'}
]
});
Create aliases for existing prototype methods. Example:
Ext.define('My.cool.Class', {
method1: function() { ... },
method2: function() { ... }
});
var test = new My.cool.Class();
My.cool.Class.createAlias({
method3: 'method1',
method4: 'method2'
});
test.method3(); // test.method1()
My.cool.Class.createAlias('method5', 'method3');
test.method5(); // test.method3() -> test.method1()
alias
( Object
/Function
object, String
methodName
) : Function
Create an alias to the provided method property with name methodName
of object
.
Note that the execution scope will still be bound to the provided object
itself.
Parameters
Returns
@利用define自定义类并且集成(extend)window
//初始化的方法
initComponent: function() {
this.callParent(arguments);
}
//定义新类
Ext.define("ux.myWin",{
//继承Window
extend:'Ext.window.Window',
width:400,
height:300,
//关键字
config: {
price: 500
},
newtitle: 'new uspcat',
mySetTitle:function(){
this.title = this.newtitle;
},
title:'uspcat',
initComponent: function() {
this.mySetTitle();
this.callParent(arguments);
}
});
@requires JS的异步加载
(function(){
//声明命名空间
Ext.Loader.setConfig({
enabled:true,
paths:{
myApp:'02/ux' //加载此目录下JS文件
}
});
创建:
var win = Ext.create("ux.myWin",{
title:'my win',
price:600,
requires:['ux.myWin']
});
@config 自动的get和set
在config中的属性可以自动生成geter和seter。并且属性第一字母会自动大写!
//定义新类
Ext.define("ux.myWin",{
//继承Window
extend:'Ext.window.Window',
width:400,
height:300,
//关键字
config: {//**************
price: 500
},
newtitle: 'new uspcat',
mySetTitle:function(){
this.title = this.newtitle;
},
title:'uspcat',
initComponent: function() {
。。。。。
}
});
//----------------
调用:
var win = new ....
alert(win.getPrice());//**************
@mixins 类的混合
Ext.define("say",{
cansay:function(){
alert("hello");
}
});
Ext.define("sing",{
sing:function(){
alert("sing hello 123");
}
});
Ext.define('user',{
//关键字
mixins :{//**************
say : 'say',
sing: 'sing'
}});
//创建类
var u = Ext.create("user",{});
u.cansay();
u.sing();
分享到:
相关推荐
ExtJS学习笔记.docExtJS学习笔记.docExtJS学习笔记.docExtJS学习笔记.doc
21. extJs 2.0学习笔记(Ext.Panel篇二) 50 22. extJs 2.0学习笔记(Ext.Panel篇三) 59 23. extJs 2.0学习笔记(Ext.Panel篇四) 62 24. extJs 2.0学习笔记(组件总论篇) 66 25. extJs 2.0学习笔记(Ext.Element API总结) ...
21. extJs 2.0学习笔记(Ext.Panel篇二) 50 22. extJs 2.0学习笔记(Ext.Panel篇三) 59 23. extJs 2.0学习笔记(Ext.Panel篇四) 62 24. extJs 2.0学习笔记(组件总论篇) 66 25. extJs 2.0学习笔记(Ext.Element API总结) ...
Extjs 5 学习笔记,在网上下载整理好的。
ExtJS4学习笔记(二)---HBox的使用 ExtJS4学习笔记(三)---VBox的使 ExtJS4学习笔记(四)---Grid的使用 ExtJS4学习笔记(五)---Grid分页 ExtJS4学习笔记(六)---多表头Grid ExtJS4学习笔记(七)---带搜索的Grid...
extjs学习笔记, 对应的书籍是extjs in action 没有看完...呵呵
EXTJS 学习笔记 ROY EXTJS学习笔记,自己学习的过程,不多但是实用
适合ExtJs开发人员extjs技术上手以及深入
根据word做的pdf版本的ExtJs学习笔记,根据原版进行了删减,欢迎大家下载啊,哈哈。
ExtJs简明教程+Extjs学习笔记,来源网络,免费奉送,我讨厌需要资源分~
老师整理的extjs学习笔记,和大家共享
extJs学习笔记,让新手能够快速理解extJS的原理,深人浅出的了解extjs的精髓。
非常适合新手学习extjs的笔记,让你少走弯路
是我学习Extjs 的学习笔记收藏整理,学习extjs的同学可以好好看看,绝对有好处,学到很多知识!
语言程序设计资料:ExtJs学习笔记-2积分.doc
自己总结的extjs4学习笔记,自己总结的extjs4学习笔记,自己总结的extjs4学习笔记,
ExtJS资料笔记(extjs各个属性的详解) ExtJS资料笔记(extjs各个属性的详解) ExtJS资料笔记(extjs各个属性的详解)