2 回答

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超4個(gè)贊
默認(rèn)情況下,Angular 會(huì)在url前面添加hashPrefix。因此,當(dāng)您導(dǎo)航到 時(shí)http://localhost:8080/admin,您不會(huì)看到 index.html,因?yàn)槟形丛L問 angular 的 ui-router 中定義的 url。您必須導(dǎo)航到http://localhost:8080/admin/#/實(shí)際處于/應(yīng)用程序狀態(tài)。
這與您的應(yīng)用程序在沒有 的情況下無法運(yùn)行的原因相同.otherwise(),因?yàn)橹笏鼤?huì)自動(dòng)將您重定向到該/狀態(tài)。
對(duì)于可能的修復(fù):
在你的.config函數(shù)中:
// This is in your app module config.
$locationProvider.html5Mode(true);
而在你的index.html:
// This is in your index.html head.
<base href="/" />

TA貢獻(xiàn)1911條經(jīng)驗(yàn) 獲得超7個(gè)贊
問題不在于沒有聲明otherwise
.
問題出在你的路線上。您將 url 指定為'/'
,這意味著只能通過http://localhost:8080/admin/而不是通過http://localhost:8080/admin訪問狀態(tài)主頁(yè)
它的otherwise
作用是什么。當(dāng)您訪問 url http://localhost:8080/admin 時(shí),路由器會(huì)嘗試找到與該 url 匹配的狀態(tài),但沒有找到。因此它重定向到與您的家鄉(xiāng)狀態(tài)匹配的http://localhost:8080/admin/。
- 2 回答
- 0 關(guān)注
- 208 瀏覽
添加回答
舉報(bào)