Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript EmberJS:更改路径以访问路由_Javascript_Model View Controller_Ember.js_Ember Router - Fatal编程技术网

Javascript EmberJS:更改路径以访问路由

Javascript EmberJS:更改路径以访问路由,javascript,model-view-controller,ember.js,ember-router,Javascript,Model View Controller,Ember.js,Ember Router,我的应用程序定义了一个Router.map。我正在使用EmberJS AppKit架构 我想使用以下路径访问我的页面配置文件: http://localhost:8000//profile 但是,我的路由名称与此路径不同,因为它是呼叫用户配置文件,所以我这样做: 路由器.js user-profile.js 当我启动应用程序时,Ember告诉我配置文件路由不存在,即使我定义了路径: 未捕获错误:断言失败:错误:断言失败:URL“/profile”与应用程序中的任何路由都不匹配 你知道我的代码现在

我的应用程序定义了一个Router.map。我正在使用EmberJS AppKit架构

我想使用以下路径访问我的页面配置文件: http://localhost:8000//profile

但是,我的路由名称与此路径不同,因为它是呼叫用户配置文件,所以我这样做:

路由器.js

user-profile.js

当我启动应用程序时,Ember告诉我配置文件路由不存在,即使我定义了路径:

未捕获错误:断言失败:错误:断言失败:URL“/profile”与应用程序中的任何路由都不匹配

你知道我的代码现在出了什么问题吗


谢谢

我猜这就是你设计路由器和名称空间的方式

通常,barebones 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”。我会尝试一下,或者如果这里没有看到其他因素,我可能会发布更多代码

此外,通常您会将路由命名为userProfile。虽然我不认为破折号化的名称是一个问题,但它并不遵循余烬命名约定


希望这能有所帮助。

我不使用ember appkit,但可以尝试使用下划线,即“user\u profile”,并重命名您的文件。只是一个不确定的结果。

我正在使用不需要此名称空间的Ember AppKit。我明白了,更多的代码仍然会有帮助。你确定实际路线了吗?App.UserProfileRoute=Ember.Route.extend{}?
export default Ember.Route.extend({
    model: function () {
        return this.store.find('user-profile');
    }
});
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...
});