ember.js - 当应用程序位于我的服务器的子目录中时,如何设置 ember.js 以使用历史记录

标签 ember.js routes localhost

所以我试图让 ember 使用历史 API 来进行路由以消除 hashbang。但是当我使用

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

我收到以下错误

Assertion failed: The URL '/ember-store/' did not match any routes in your application

我在本地主机服务器上使用 MAMP,所有项目都只是 htdocs 文件夹中的子文件夹。该 ember.js 应用程序的整个应用程序和 index.html 文件所在的文件夹称为“ember-store”。如何解决此问题以便正确使用历史记录 API?

最佳答案

如果您希望 Ember 应用程序在路径段内路由,您需要告诉 Ember 路由器您的根 URL 是什么。要在您的情况下执行此操作,请将上面的代码更改为:

App.Router.reopen({
    location: 'history',
    rootURL: '/ember-store/'
});

http://emberjs.com/guides/routing/#toc_specifying-a-root-url

关于ember.js - 当应用程序位于我的服务器的子目录中时,如何设置 ember.js 以使用历史记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22407194/

相关文章:

regex - 带有约束的 Rails 自定义路由 - 路由要求中不允许使用正则表达式 anchor 字符

http - 从另一台 PC 向在本地主机上运行的 API 服务器发送 HTTP POST

php - 我无法在我的数据库中插入数据。我哪里错了?

ember.js - 如何自定义ember数据的restful URL和修改HTTP方法

javascript - Ember : insert errors from model into application template

javascript - 对多个嵌套 ember 路由使用相同的 URL

Laravel 路由参数在单元测试中返回 null

ember.js - emberjs-2.0 点击时动态添加更多组件

html - Express 正确定义 post 路由方法

google-chrome - 带有 Chrome 的 Visual Studio Code 调试器拒绝连接到本地主机