2014-01-22 48 views
0

視圖我下面道場移動教程Part 2了404錯誤,當負載定製道場延伸JS

而且要實現延長滾動視圖。我把代碼放在FeedView.js和SettingsView.js中,然後調用它們。但是當加載它們時,會顯示此錯誤。我怎麼修復它?

Failed to load resource: the server responded with a status of 404 (Not Found) http://127.0.0.1/demo/js/FeedView.js

我把我的代碼下的nginx服務器,目錄結構是這樣的

演示
_js
      _FeedView.js
      _SettingsView.js
_index .html

這裏是HTML文件

<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
    <meta name="viewport" 
     content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" /> 
    <meta name="apple-mobile-web-app-capable" content="yes" /> 

    <!-- prevent cache --> 
    <meta http-equiv="cache-control" content="no-cache"> 
    <meta http-equiv="pragma" content="no-cache"> 
    <title>Dojo Mobile tutorial | Flickrview | Part II | Mockup</title> 

    <!-- application stylesheet --> 
    <link rel="stylesheet" type="text/css" href="css/flickerview.css"> 

    <!-- dynamically apply native visual theme according to the browser user agent --> 
    <script type="text/javascript" 
     src="http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojox/mobile/deviceTheme.js"></script> 

    <!-- dojo configuration options --> 
    <script type="text/javascript"> 
     dojoConfig = { 
      async : true, 
      baseUrl : './', 
      parseOnLoad : false, 
      mblHideAddressBar : true, 
      packages : [ { 
       name : "test", 
       location : "js" 
      } ] 
     }; 
    </script> 

    <!-- dojo bootstrap --> 
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo/dojo.js" data-dojo-config="async:true"></script>  

    <!-- dojo application code --> 
    <script> 
     // Load the widget parser and mobile base 
     require([ "dojox/mobile/parser", "dojox/mobile/compat", "dojo/domReady!", "test/FeedView", "test/SettingsView" ], function(parser) { 
      // Parse the page for widgets 
      parser.parse(); 
     }); 
    </script> 
</head> 
<body> 
    <!-- Settings view --> 
    <div id="settings" data-dojo-type="test/SettingsView"> 
    ... 
     </div> 
</body> 
</html> 
+2

驗證您的文件夾結構與URL的結構是否相同(例如'demo/js/FeedView.js'),它說它無法找到它,所以您的文件夾結構必須錯誤。試着直接從你的瀏覽器找到你的'FeedView.js'文件,如果這不起作用,那麼你的結構不正確或者你有權限問題。 – g00glen00b

+0

感謝Dimitri,問題已修復,根本原因是FeedView.js的文件名錯誤。 – carmentian

回答

0

看來我的意見解決你的問題,但我認爲這可能是更容易(以備將來參考),我寫下一個合適的回答也是如此。

您的錯誤表明它無法在給定的位置找到該文件。驗證位於http://127.0.0.1/demo/js/FeedView.js的文件確實存在。如果它不存在,檢查以下內容:

  • 確認位置/目錄結構真的正確。文件名(區分大小寫),擴展名,文件夾結構......他們都很重要。
  • 驗證權限是否設置正確。我只熟悉Apache webserver,但是如果你的文件沒有正確的權限,它不會顯示出來。

如果URL道場是看是錯誤的(該文件存在,但在另一個lcoation),那麼你可能在你的包/模塊配置/命名犯了一個錯誤。

什麼道場實際執行時加載的模塊如下:

  1. 道場着眼於包加載模塊的,在這種情況下test/FeedView

  2. 道場覈實,如果包是在dojoConfig中配置,如果它不存在,那麼它將嘗試在相對於Dojo加載器的文件夾中檢索模塊(在本例中爲CDN版本)。

  3. 如果包確實存在(如在這種情況下),它會使用該位置,這將在這種情況下返回以下網址:

    的http:// + + + +。JS

或者你的情況:

http://127.0.0.1/demo + ./ + js + /FeedView + .js 

一起:

http://127.0.0.1/demo/js/FeedView.js 

而這確實是URL道場是想看看。

+0

非常感謝Dimitri的幫助。 ; ) – carmentian

+0

@carmentian很晚:p雖然沒問題 – g00glen00b