簡體   English   中英

Ember JS入門套件自動定位路由

[英]Ember JS Starter Kit Auto Location Routing

我從首頁下載了入門工具包-版本1.8.1。

我將以下內容放入app.js文件中:

App.Router.map(function() {
    this.route('about');
    this.route('gallery');
    this.route('contact');
});

然后遵循:

App.Router.reopen({
    location: 'auto'
});

然后,我在index.html文件中構建了所需的模板。 當我將位置放在“哈希”位置時,應用程序運行良好,但是當我在此處api文檔中閱讀到“ auto”位置時,它拋出錯誤,提示“ index.html”與您應用程序中的任何路由都不匹配。 我的想法是從網址中刪除哈希符號。

我正在使用Chrome 39.0.2171.71版

有人能解釋為什么會這樣嗎?

Chrome支持它,但是ember入門工具包僅為您提供文件目錄。 當您導航到/index.html/foo ,您的操作系統並不知道您確實只想停留在index.html頁面上。

在您鏈接的位置頁面上,它討論了這一點。 Keep in mind that since some of your users will use HistoryLocation, your server must serve the Ember app at all the routes you define.

此外,使用歷史記錄時,您可能需要設置rootURL: http ://emberjs.com/guides/routing/#toc_specifying-a-root-url

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM