繁体   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