2016-07-04 46 views
0

我的Angular Dart網站在發佈服務時運行良好。我寧願用Apache運行它。當我輸入網址jazzcat.loc/index.html的我得到以下瀏覽器錯誤:在Apache上運行AngularDart

GET http://jazzcat.loc/packages/browser/dart.js index.html:22 
GET http://jazzcat.loc/packages/polymer/polymer.dart package:polymer/polymer.dart:1 
An error occurred loading file: package:polymer/polymer.dart index.html:22 
GET http://jazzcat.loc/packages/angular2/platform/browser.dart package:angular2/platform/browser.dart:1 
An error occurred loading file: package:angular2/platform/browser.dart 
index.html:22 GET http://jazzcat.loc/packages/jazzcat/app_component.dart package:jazzcat/app_component.dart:1 
An error occurred loading file: package:jazzcat/app_component.dart favicon.ico:1 
GET http://jazzcat.loc/favicon.ico 404 (Not Found) 

該網站的虛擬主機條目爲:

<VirtualHost *:80> 
    ServerName jazzcat.loc 
    DocumentRoot /Volumes/Data/htdocs/jazzcat/web 

    <directory /Volumes/Data/htdocs/jazzcat/web> 
    Allow from all 
    Options -MultiViews 
    Require all granted 
    </directory> 
</VirtualHost> 

沒有.htaccess文件

這是index.html的:

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Jazz Cat</title> 
    <script> 
     window.Polymer = window.Polymer || {}; 
     window.Polymer.dom = 'shadow'; 
    </script> 

    <!-- For testing using pub serve directly use: --> 
    <base href="/"> 
    <!-- For testing in WebStorm use: --> 
    <!-- base href="/dart/web/" --> 

    <link href="master.css" rel="stylesheet" type="text/css" /> 
    <script defer src="main.dart" type="application/dart"></script> 
    <script defer src="packages/browser/dart.js"></script> 
    </head> 
     <my-app>Loading...</my-app> 
</html> 

我使用

也嘗試
<base href="/dart/web/"> 

它也出錯了。我正在Chromium瀏覽器中測試。

我在這裏看到有關路由的問題和解答。它們似乎適用於index.html之外的路由。

回答

1

AFAIK pub serve意味着在開發過程中要使用的,如果你想使用Apache,以滿足您的應用程序,你可能需要使用pub build轉換(優化)您的應用程序到定期 HTML + JavaScript的應用程序,here you might find more information

+0

...或者切換到「HashLocationStrategy」或確保服務器支持HTML5 pushstate http://krasimirtsonev.com/blog/article/apache-htaccess-for-html5-push-state-manipulations。另請參閱http://stackoverflow.com/questions/36861628/location-and-hashlocationstrategy-stopped-working-in-beta-16 –

+0

現在我想到了,這是有道理的。 – curt

+0

@GünterZöchbauer,HashLocationStrategy與pub服務一起工作嗎?我也無法重新加載頁面,並閱讀了關於該問題的幾個問題和答案,但他們沒有提及他們在哪個環境下實施修補程序。我不想浪費時間去嘗試一些不適合與酒吧服務合作的事情。 – curt