1.用js创建原生对象
function user(){
//相当于java中public
this.name='tianci';
this.age=22;
//相当于 private
var email='tiancig@gmail.com';
//this 是可以外部暴露的
this.getEmail=function(){
return email;
}
}
var u=new user();
//alert(u.name);
alert(u.getEmail());
2.extjs创建对象
var win=new Ext.window.Window({
width: 400,
height: 300,
title: 'tianci'
});
// win.show();
//1.得到按钮的 dom对象
//2.为按钮添加单机事件
//3.单击的时候 调用win的show方法
Ext.get('myb').on('click',function(){
win.show();
});
3.extjs定义对象
Ext.define("ux.myWin", {
extend: 'Ext.window.Window',
width: 400,
height: 300,
config:{
price:500 //生成 set get 方法
},
title: 'tianci',
newTitle: 'new Title',
mySetTitle: function(){
this.title = this.newTitle;
},
initComponent: function(){
this.mySetTitle();
this.callParent(arguments);
}
});
注: 加 config 后 里面的属性 自定生成 set get 方法