Ext学习之2_config1
Ext.namespace("com.deng");
/**
在EXT中初始化对象时,大量使用了config参数,config不过就一个json对象,举例说明
*/
/**
//定义Student类
Student = function(name,sex){
??? this.name = name;
??? this.sex = sex;
}
//测试
var student = new Student("zhangshan","男");
alert(student.name);
*/
//用json对象作为构造参数的对象
/**
Student = function(config) {
??? this.name = config.name;
??? this.sex = config.sex;
}
//测试
var student = new Student({name:"张山", sex:"男"});
alert("姓名:"+ student.name +"\r\n性别:" + student.sex);
*/
//假如有一万个属性,那我们就要写一万个属性赋值了,这太麻烦,Ext有解决办法
Student = function(config) {
??? Ext.apply(this,config);
}
//测试
var student = new Student({name:"zhangshan",sex:"男"});
alert("姓名:" + student.name + "\r\n性别:" + student.sex);
/**
?* 备注:Ext的apply方法是将第2个参数的成员赋给第一参数
?*/