<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title id="page-title">클래스 믹스인</title>
    <script type="text/javascript" src="ext.js"></script>   
	<script type="text/javascript">
	
		Ext.define('LeftSword',{
			
			leftSkill : function(){
				console.log( "left sowrd skill 발동" ) ; 
			}, 
			
			commonSkill : function(){
				console.log( "left common skill 발동" ) ; 
			}
			
			
		}); 
		
		Ext.define('RightSword',{
			mixins : {
				leftSword : 'LeftSword'
			} , 
			
			leftSkillUse : function(){
				this.leftSkill(); 
			} , 
			
			commonSkill : function(){
				console.log( "right common skill 발동" ) ; 
			} , 
			
			leftCommonSkill : function(){
				// mixins 로 결합된 method 중 method name이 겹치는 method 호출하는 방법임. 
				this.mixins.leftSword.commonSkill.call( this ) ; 
			} 			
			
		});
		
		var sword = Ext.create('RightSword') ; 
		
		// 출력 : left sowrd skill 발동
		sword.leftSkillUse(); 
		
		// 출력 : right common skill 발동 
		// 본인 method 우선순위 가짐 
		sword.commonSkill(); 
		
		// 출력 : left common skill 발동 
		sword.leftCommonSkill(); 
		
		
	</script>   
	
</head>
<body>
	1. 클래스 믹스인 <br/>
	- 상속이 아닌 두 개의 클래스를 결합하는 것임. 
</body>
</html>


블로그 이미지

나무뚱이

,