Ext.onReady(function(){
// if(Ext.BLANK_IMAGE_URL.substring(0, 4) != "data"){
// Ext.BLANK_IMAGE_URL = "./images/s.gif";
// }
//hello world
// new Ext.Viewport({
Ext.create('Ext.Viewport',{
layout:'fit',
items:[{
xtype:"panel",
title:"欢迎",
html:"<h1 style='text-align:center;font-size:60px;'>Hello World</h1>"
}]
})
//Ext.widget('',{})与Ext.create类是,只是第一个参数使用类的别名
//Ext.ns("Ext.Myapp","Ext.Myapp.data")命名空间
// Ext.define(classname,properties,callback)定义新类callback可省去
//定义Calculator类
Ext.define("Calculator",{
construtor:function(){
return this;
},
plus:function(v1,v2){
return v1+v2;
},
minus:function(v1,v2){
return v1-v2;
},
multiply:function(v1,v2){
return v1*v2;
},
didvid:function(v1,v2){
return v1/v2;
}
})
var cal = new Calculator();
cal.plus(87,28);
cal.minus(87,28);
cal.multiply(7,8);
cal.didvid(16,2);
//定义子类
Ext.define("BIN",{
bin:function(v1){ //十进制转二进制
return v1.toString(2);
}
});
Ext.define("NewCalculator",{
extend: "Calculator",
mixins:{
Bin:"BIN"
},
hex:function(v1){ //十进制转十六进制
return v1.toString(16);
},
convert:function(v1,type){
switch(type){
case 2:
return this.bin(v1);
break;
case 16:
return this.hex(v1);
break;
}
}
});
var ncal = new NewCalculator();
ncal.hex(28);
ncal.convert(28,16);
ncal.convert(17,2);
})