【发布时间】:2012-04-20 00:33:54
【问题描述】:
我有一个尝试使用ember-routemanager 的应用程序。 (我使用rake-pipeline 作为我的构建环境,但我认为这无关紧要。或者是吗?)问题是,该应用似乎忽略了位置栏中的路线。
This jsfiddle 显示状态管理器正确设置并进入入口状态。两秒半后,脚本运行App.stateManager.set('location', 'desktop');,根据 ember-routemanager README 应该将我移动到以“桌面”作为其路由参数的状态(对吗?)。但事实并非如此。
(这是我在 jsfiddle 中克隆问题的最接近的方法,我无法轻易在位置栏中放置路径。当我在我的开发环境中这样做时,例如 http://localhost:9292/desktop 或 http://localhost:9292/#desktop ,很明显应用程序没有使用路径;它返回“找不到实体:/desktop”。)
请注意,another version of the same fiddle 使用 goToState 而不是设置 location 可以正常工作。
我做错了什么?
代码:
Sylvius.stateManager = Ember.RouteManager.create({
initialState: 'launch',
enableLogging: true,
wantsHistory: true,
launch: Em.ViewState.create({
view: Sylvius.LaunchView,
}),
desktop: Em.ViewState.create({
view: Sylvius.DesktopView,
route: 'desktop',
sectionSelected: Em.State.create({
route: ':sectionSlug',
enter: function(manager, transition) {
console.log('We found the slug: ' + Sylvius.stateManager.getPath('params.sectionSlug'));
}
})
})
});
【问题讨论】:
标签: url-routing ember.js