第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

沒有 urlRouterProvider 的 ui 路由。否則

沒有 urlRouterProvider 的 ui 路由。否則

Go
回首憶惘然 2021-11-29 15:41:06
如果我不包含 $urlRouterProvider.otherwise('/'); 則不會(huì)發(fā)生路由。在配置中。我的 go 應(yīng)用引擎設(shè)置與 gorilla 是r := mux.NewRouter()r.HandleFunc(/admin, handleAdmin)和 angularjs 配置是;angular.module('admin')    .config(function($stateProvider, $urlRouterProvider) {      $stateProvider.state('home', {        url: '/',        templateUrl: '/admin/index.html',        controller: 'AdminController as admin'      });  //$urlRouterProvider.otherwise('/');})當(dāng)我不調(diào)用 $urlRouterProvider.othwerwise 行,并打開http://localhost:8080/admin我希望看到 admin/index.html,但我沒有。只有當(dāng)我手動(dòng)導(dǎo)航到http://localhost:8080/admin#/時(shí),我才能看到它。但是如果我添加 $urlRouterProvider.othwerwise 選項(xiàng)并轉(zhuǎn)到http://localhost:8080/admin它會(huì)自動(dòng)重定向到http://localhost:8080/admin#/ 我不認(rèn)為這是通常的方法,因?yàn)槲铱赡芟M胺駝t”路由到自定義 404 頁(yè)面。我錯(cuò)過了什么?
查看完整描述

2 回答

?
慕的地8271018

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="/" />


查看完整回答
反對(duì) 回復(fù) 2021-11-29
?
Smart貓小萌

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/


查看完整回答
反對(duì) 回復(fù) 2021-11-29
  • 2 回答
  • 0 關(guān)注
  • 208 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)