2012-12-29 39 views
3

無法加載模塊我在index.html的這個超級簡單的代碼錯誤:在道場

<script src="../../dojo/dojo.js"></script> 
<script> 
    dojo.require("dojo.fx"); 
    dojo.ready(function(){ 
     dojo.byId("greeting").innerHTML += ", from " + dojo.version; 
     dojo.fx.slideTo({ 
      top: 100, 
      left: 200, 
      node: dojo.byId("greeting") 
     }).play(); 
    }); 
</script> 

我得到錯誤 錯誤:無法加載「dojo.fx」;最後嘗試'./fx.js'

注意:我沒有改變dojo的目錄結構。我正在使用dojo 1.6

-dojo 
-dijit 
-dojox 
-labs 
-ex01 
    -index.html 
+0

uhm,你真的使用dojo-version嗎? – nozzleman

+0

版本是1.6.1 – John

+0

你也可以嘗試從其他來源(比如谷歌雲)加載dojo Willmore

回答

1

問題是道場根本就不會從我的本地文件系統中運行。

Run your source code from a web server, not the file system, even if the web server is running on your development machine. The browser's handling of HTTP requests from the local file system are more restrictive than from a web server, even when it's running in the same machine. For consistent results, you should always run Dojo from within any HTTP web server (Apache, nginx, Tomcat, IIS, Jetty, etc.).

0

你的代碼工作得很好。我已經安裝使用Dojo 1.6這裏的jsfiddle:http://jsfiddle.net/6h82P/

這裏有一個完整的例子:

<!DOCTYPE html> 
<html> 
    <head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
    <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js.uncompressed.js'>    </script> 
    </head> 
    <body> 
    <div id="greeting">Hello</div> 
    <script> 
     dojo.require("dojo.fx"); 
     dojo.ready(function(){ 
     dojo.byId("greeting").innerHTML += ", from " + dojo.version; 
     dojo.fx.slideTo({ 
     top: 100, 
     left: 200, 
     node: dojo.byId("greeting") 
     }).play(); 
    }); 
    </script> 

    </body> 
</html>