【问题标题】:Running AngularDart on Apache在 Apache 上运行 AngularDart
【发布时间】:2016-07-04 22:20:14
【问题描述】:

我的 Angular Dart 网站在 pub serve 上运行良好。我宁愿用 Apache 运行它。当我输入 url jazzcat.loc/index.html 时,出现以下浏览器错误:

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 之外的路由。

【问题讨论】:

    标签: apache dart angular-dart


    【解决方案1】:

    AFAIK pub serve 旨在在开发过程中使用,如果您想使用 apache 为您的应用程序提供服务,您可能需要使用 pub build 将您的应用程序转换(和优化)为 常规 em> html+javascript 应用,here you might find more information.

    【讨论】:

    • ... 你要么切换到HashLocationStrategy,要么确保服务器支持HTML5 pushstate krasimirtsonev.com/blog/article/…。另见stackoverflow.com/questions/36861628/…
    • 现在我想起来了,这是有道理的。
    • @GünterZöchbauer,HashLocationStrategy 是否适用于 pub 服务?我也无法重新加载页面并阅读了有关该问题的几个问题和答案,但他们没有提及他们在哪个环境下实施修复。我不想浪费时间尝试一些不适用于 pub serve 的东西。
    • pub serve 仅支持HashLocationStrategy。 AdaoJunior 构建了一个简单的工具,允许使用 pub servePathLocationStrategy pub.dartlang.org/packages/pub_serve_rewrites 一起使用。也例如当nginx用作转发到pub serve的代理时,您可以配置nginx使pub servePathLocationStrategy一起制作(我自己不知道nginx,这只是一个例子)
    猜你喜欢
    • 1970-01-01
    • 2017-03-11
    • 2015-05-23
    • 2018-11-19
    • 2014-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多