首页 > Web开发 > 详细

ExtJs--08--Ext自定义类的继承关系

时间:2014-11-12 16:38:45      阅读:203      评论:0      收藏:0      [点我收藏+]
Ext.onReady(function(){
	
	//子类集成父类
	
	Ext.define("Person",{
		config:{
		name:"",
		age:0,
		sex:""
		},
		say:function(){
			Ext.Msg.alert("标题信息","用户提示信息");
		},
		constructor:function(config){
			 var me = this ; 
			 me.initConfig(config);
		}
	});
	
	Ext.define("Student",{
		extend:"Person",     //继承关系
		config:{
		},
		run:function(){
			Ext.Msg.alert("子类标题信息","子类用户提示信息")
		},
		constructor:function(config){
			var me = this ; 
			me.initConfig(config);
		}
	})
	
	var stu1 = Ext.create("Person",{
		name:"老公",
		age:22,
		sex:"女"
	});
	window.alert(stu1.getName())
	stu1.say()
	
	var stu2 = Ext.create("Student",{
		name:"学生",age:23,sex:"男"		
	});
	window.alert(stu2.age)
	stu2.say()  //拿到的是父类的say方法
	alert("------------");
	stu2.run() //拿到的是子类的run方法
	
	
});

ExtJs--08--Ext自定义类的继承关系

原文:http://blog.csdn.net/responsecool/article/details/41044077

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!