【发布时间】:2018-10-11 09:52:20
【问题描述】:
我无法让我的 Angular 5 应用程序在 WAMP 服务器中运行。我已经阅读了许多其他堆栈溢出帖子并尝试了一些选项。
dist 文件夹制作步骤:
第 1 步 - ng build --prod --base-href "/dist/"。
第 2 步:将 dist/* 文件复制到 DOCUMENT_ROOT。
第 3 步 - 重新启动 WAMP 服务器
第 4 步 - 本地主机。 dist 文件夹显示在 WAMP 中
第 5 步:localhost/dist 和 localhost/dist/index.html - 没有任何效果
第 6 步:我将基本 href 更改为“/dist/”并重新启动 WAMP - 此打开的索引文件 Dint work
第 7 步 - 基于 Angular 站点中给出的部署方法 -https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml
我创建了 .htaccess 文件并复制了以下代码并将文件放在 dist 文件夹中 enter image description here
仍然路由不工作。请帮忙。过去 3 天都在为此苦苦挣扎!
【问题讨论】:
-
使用 /dist 代替 /dist/
-
谢谢@ulrich - 不工作 - 我试过 1. 创建新的 dist 文件夹使用 - ng build --prod --build-href "/dist" - 检查了我的 index.html 文件但基本 href仍然 ”/”。 2.自己在索引文件中将base href从“/”更改为“/dis”,重新启动wamp服务器。仍然没有输出。
-
您使用的是哪个版本的 CLI?设置 base-href 时是否收到警告?
标签: angular .htaccess deployment wampserver