【Dojo学习之四】Dojo语法

前端之家收集整理的这篇文章主要介绍了【Dojo学习之四】Dojo语法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Dojo的语法,哎,就不解释了,说一下我学习时候遇到的问题的地方

1.关于dojo多方法链接的问题,dojo的强大之处,因为javascript是单线程语言,所以dojo通过自己的方法连接了多个方法

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<Meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>多方法连接</title>
<script type="text/javascript" djConfig="parSEOnLoad: true,isDebug: true" src="./dojo/dojo/dojo.js"></script>
<script type="text/javascript">
</script>
<script>

    var mineObj = { 
	    aMethod: function(){  
	        console.log('running A');
	    },bMethod: function(){  
	        console.log('running B');  
	    }     
	};  
	var otherObj = {  
	    cMethod: function(){  
	        console.log('running C');   
	    }  
	};    
	dojo.addOnLoad(function(){  
	    // run bMethod() whenever aMethod() gets run  
	    dojo.connect(mineObj,"aMethod",mineObj,"bMethod");   
	    // run an entirely different object's method via a separate connection  
	    dojo.connect(mineObj,"bMethod",otherObj,"cMethod");   
	    // start chain of events 
	    mineObj.aMethod();  
	}); 
</script>
</head>
<body>

</body>
</html>

猜你在找的Dojo相关文章