2016-11-16 22 views
0

我在直接訪問鏈接時沒有經過路由href錨點就有問題。例如,站在頁面上並點擊刷新,或者在瀏覽器窗口中複製粘貼鏈接。直接訪問郊區而不經過錨點會給Aurelia帶來錯誤

是什麼在起作用:

http://localhost:9000/boards

http://localhost:9000/cards

什麼不起作用:

http://localhost:9000/boards/1

http://localhost:9000/boards/anysuburl

錯誤我得到的是:

GET http://localhost:9000/boards/scripts/vendor-bundle.js 404 (Not Found) 

如果我包供應商,從路徑更改爲:

<script src="scripts/vendor-bundle.js" data-main="aurelia-bootstrapper"></script> 

到:

<script src="/scripts/vendor-bundle.js" data-main="aurelia-bootstrapper"></script> 

廠商束得到解決,但我得到了同樣的錯誤on app-bundle.js

路由器如何設置:

 configureRouter(config, router) { 
config.title = 'Aurelia'; 
config.options.pushState = true; 
config.options.root = '/'; 
config.map([ 
    { 
    route: ['', 'cards'], 
    name: 'cards', 
    moduleId: './pages/cards/cards', 
    nav: true, 
    title: 'Cards', 
    }, 
    { 
    route: ['boards'], 
    name: 'boards', 
    moduleId: './pages/boards/index', 
    nav: true, 
    title: 'Boards', 
    }, 
    { 
    route: ['boards/:id'], 
    name: 'board', 
    moduleId: './pages/boards/details', 
    title: 'Board', 
    } 

我已經試過「/頁」,」 ./pages'和‘頁’具有相同的結果

+0

你有一個基地標籤定義? https://developer.mozilla.org/en/docs/Web/HTML/Element/base – mgiesa

+0

基本標籤建議修復問題。謝謝:) – Sathees

+0

太好了。我已經添加它作爲答案 – mgiesa

回答

1

基地的標籤添加到您的HTML,像這樣:

<base href="/"> 
相關問題