Dojo的语法,哎,就不解释了,说一下我学习时候遇到的问题的地方 1.关于dojo多方法链接的问题,dojo的强大之处,因为javascript是单线程语言,所以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>