我为我的应用程序定义了一个Router.map。我正在使用EmberJS AppKit体系结构。https://github.com/stefanpenner/ember-app-kit
我想使用以下路径访问我的页面“配置文件”:http://localhost:8000/#/profile
但是,我的路径名与这个路径不同,因为它调用了user-profile,所以我这样做了:
router.js
var Router = Ember.Router.extend();
Router.map(function () {
this.resource('user-profile', { path: 'profile'}, function() {
//Some other things...
});
});
export default Router;user-profile.js
export default Ember.Route.extend({
model: function () {
return this.store.find('user-profile');
}
});启动应用程序时,Ember告诉我profile路由不存在,尽管我定义了路径:
Uncaught Error: Assertion Failed: Error: Assertion Failed: The URL '/profile' did not match any routes in your application
你知道我的代码有什么问题吗?
谢谢
发布于 2014-05-18 01:58:36
我不使用ember,但可能尝试下划线,即'user_profile‘和重命名您的文件太。只是黑暗中的一枪。
发布于 2014-05-07 20:31:02
我不得不猜测,这就是您设计路由器和命名空间的方式。
通常,一个简单的Ember应用程序需要:
window.App = Ember.Application.create({
LOG_TRANSITIONS: true,
LOG_TRANSITIONS_INTERNAL: true
});
App.Router.map(function () {
this.resource('user-profile', { path: 'profile'}, function() {
//Some other things...
});在您的示例中,您的路由器不在App名称空间中,也不包括您的根对象名称(它不一定是'App')。如果这里没有其他因素,我会尝试这样做,或者发布更多的代码。
另外,通常您会将路由命名为userProfile。虽然我不认为这个名称是一个问题,但它并不遵循Ember命名规则。
希望这能有所帮助。
https://stackoverflow.com/questions/23527299
复制相似问题