【发布时间】:2015-08-01 08:01:11
【问题描述】:
问题是路由在 emberJS 中没有被识别,即使它在 router.js 中以“正确”格式指定,如 emberJS 文档 1.13.0 中所示。这是它现在的样子:
this.route('business', {path: '/business'}, function(){
this.route('dashboard', {path:'/dashboard/:business_name'})
});
我在路线/业务下有一个路线仪表板,其中显示以下内容:
export default Ember.Route.extend({
model: function(){
return this.store.find('business');
}
});
无论该人是否已成功登录,这里是重新路由到网页的路由代码:
var _this = this;
var user = $.ajax({
type: "POST",
url: "http://path/to/login",
data: {
emailAddress: this.get('model.emailAddress'),
password: this.get('model.password')
}
}).then(function(response, request){
if(response != null){
business.set('businessName', response.business.business_name);
business.save('no post'); //I override the .save() so it won't do a post request
_this.transitionToRoute('business.dashboard', business);
}
else{
//skip the welcome part
}
});
尽管使用以前生成新路线的方法(我可能会成功添加),但我不知道为什么它会给我这个错误:
未捕获的错误:没有名为 Dashboard 的路由
【问题讨论】:
-
您显示的代码看起来不错,除了
{path: '/business'}应该是。你应该多展示一些代码。你是怎么得到这个错误的? -
嘿@Artych,我做了路径:'/business'。我添加了 transitionToRoute
-
我四处打听,ember 开发人员说这可能与路由有关,模型未正确传递或类似问题。顺便说一句,我是余烬菜鸟。