Extjs4 类定义创建和特性
2012-11-11 21:54
155 查看
//类的声明其实就是一个fuction
function user(){
this.name='uspcat';
this.age=26; //var 就相当于高级语言中的private
var email="dd163.com";
this.getEmail=function(){
return email;
} }
//1 js创建一个对象 var u=new user();
//alert(u.name);
//alert(u.getEmail())
//2 js创建一个对象
var person={ name:'yfc', age:26 };
//alert(person.name+" "+person['age'])
*/
(function() {
// 声明一个命名空间
Ext.Loader.setConfig({
enabled : true,
paths : {
myApp : 'extstudy/ux'
}
});
Ext.onReady(function() {/*
* var win = new Ext.window.Window({ title :
* 'Hello', height : 200, width : 400
*
* }); // win.show(); //
* 1.得到按钮的dom对象;2.为按钮添加单击事件。3.单击时调用win的show方法
*
* Ext.get("myb").on("click", function() {
* win.show(); });
*
*/
// 1. 创建一个函数对象,用一个别名创建一个对象
var o = {
say : function() {
// alert(111);
}
}
var fn = Ext.Function.alias(o, 'say');
fn();
// 2创建一对象4.0提倡使用create创建对象
/*
* var win = Ext.create('Ext.window.Window', {
* width : 400,
* height : 300,
* title : 'uspcat' });
* win.show();
*/
// 3.自定义一个类,( 类之间的继承)
/*
* Ext.define("myWin",{
* extend:'Ext.window.Window',
* width:400,
* height:300,
* title:'uspcast',
* newtitle:'new uspcat',
* mySetTitle:function(){
* this.title=this.newtitle;
* },
* initComponent:function(){
* this.mySetTitle();
* this.callParent(arguments);
* }
*
* });
*/
// 实例化一个类对象
Ext.get('myb').on("click", function() {
var win = Ext.create("ux.mywin", {
title : 'my win',
price : 600,
requires : ['ux.mywin']
// 是否异步加载ux底下mywin.js
});
alert(win.getPrice());
});
Ext.define("say", {
cansay : function() {
alert("hello");
}
});
Ext.define("sing", {
sing : function() {
alert("sing hello111");
}
});
Ext.define('user', {
mixins : {// 混合对象,其实就是类直接的调用,实现类的多继承,在extjs中
say : 'say',
sing : 'sing'
}
});
var u = Ext.create("user", {});
u.cansay();
u.sing();
});
})();
mywin.js
Ext.define("ux.mywin", {
extend : 'Ext.window.Window',
width : 400,
height : 300,
config:{
hashTouchScreen:false,
operationSystem:'other',
price:50
},
title : 'ucast',
newtitle : 'new uspcat',
mySetTitle : function() {
this.title = this.newtitle;
},
initComponent : function() {
this.mySetTitle();
this.callParent(arguments);
}
});
function user(){
this.name='uspcat';
this.age=26; //var 就相当于高级语言中的private
var email="dd163.com";
this.getEmail=function(){
return email;
} }
//1 js创建一个对象 var u=new user();
//alert(u.name);
//alert(u.getEmail())
//2 js创建一个对象
var person={ name:'yfc', age:26 };
//alert(person.name+" "+person['age'])
*/
(function() {
// 声明一个命名空间
Ext.Loader.setConfig({
enabled : true,
paths : {
myApp : 'extstudy/ux'
}
});
Ext.onReady(function() {/*
* var win = new Ext.window.Window({ title :
* 'Hello', height : 200, width : 400
*
* }); // win.show(); //
* 1.得到按钮的dom对象;2.为按钮添加单击事件。3.单击时调用win的show方法
*
* Ext.get("myb").on("click", function() {
* win.show(); });
*
*/
// 1. 创建一个函数对象,用一个别名创建一个对象
var o = {
say : function() {
// alert(111);
}
}
var fn = Ext.Function.alias(o, 'say');
fn();
// 2创建一对象4.0提倡使用create创建对象
/*
* var win = Ext.create('Ext.window.Window', {
* width : 400,
* height : 300,
* title : 'uspcat' });
* win.show();
*/
// 3.自定义一个类,( 类之间的继承)
/*
* Ext.define("myWin",{
* extend:'Ext.window.Window',
* width:400,
* height:300,
* title:'uspcast',
* newtitle:'new uspcat',
* mySetTitle:function(){
* this.title=this.newtitle;
* },
* initComponent:function(){
* this.mySetTitle();
* this.callParent(arguments);
* }
*
* });
*/
// 实例化一个类对象
Ext.get('myb').on("click", function() {
var win = Ext.create("ux.mywin", {
title : 'my win',
price : 600,
requires : ['ux.mywin']
// 是否异步加载ux底下mywin.js
});
alert(win.getPrice());
});
Ext.define("say", {
cansay : function() {
alert("hello");
}
});
Ext.define("sing", {
sing : function() {
alert("sing hello111");
}
});
Ext.define('user', {
mixins : {// 混合对象,其实就是类直接的调用,实现类的多继承,在extjs中
say : 'say',
sing : 'sing'
}
});
var u = Ext.create("user", {});
u.cansay();
u.sing();
});
})();
mywin.js
Ext.define("ux.mywin", {
extend : 'Ext.window.Window',
width : 400,
height : 300,
config:{
hashTouchScreen:false,
operationSystem:'other',
price:50
},
title : 'ucast',
newtitle : 'new uspcat',
mySetTitle : function() {
this.title = this.newtitle;
},
initComponent : function() {
this.mySetTitle();
this.callParent(arguments);
}
});
相关文章推荐
- SharePoint2010新特性:InfoPath定义创建列表的界面
- SharePoint2010新特性:InfoPath定义创建列表的界面
- SharePoint2010新特性:InfoPath定义创建列表的界面
- BI之SSAS完整实战教程6 -- 设计维度、细化维度上:创建维度定义特性关系
- Extjs4.0 的类定义创建和一些新特性介绍
- lucene创建索引高级特性和索引创建参数优化
- C#动态创建类和使用特性增强程序可扩展性
- Linux 下使用POSIX中为线程创建和同步定义的API时遇到的问题
- MySQL中视图的定义、原理和如何使用、创建
- C#特性学习与使用(为枚举定义Description)
- Oracle11新特性——支持对物化视图日志的在线重定义
- 创建Material Design风格的Android应用--定义阴影和裁剪视图
- lucene创建索引高级特性和索引创建参数优化
- 二叉树要掌握的知识点(-)(定义、创建、先中后序遍历、求深度)
- 21天学通JAVA:类的定义和对象的创建
- 定义范围中的备选方案生成、横向思维、创建WBS、工作包定义、WBS、确认范围过程和实施质量过程的关系、联合应用设计和质量功能展开QFD
- JavaScript对象的创建之外部属性定义方式(基于已有对象扩充其属性和方法)
- ABAP 7.4新特性(一):行内定义 Inline Declarations
- java语言高级特性(一)多线程创建、交互
- Google Android开发者文档系列-创建有内容分享特性的应用之添加一个简单的共享action