Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.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
Ember.js Js使用带有动态段的Transitiono路由_Ember.js - Fatal编程技术网

Ember.js Js使用带有动态段的Transitiono路由

Ember.js Js使用带有动态段的Transitiono路由,ember.js,Ember.js,我有一个余烬应用程序(版本3.14),我想转换到一个带有动态段的路线 当用户访问/projects/other时,我想重定向到/projects/other/2020 我更改了我的项目/其他路线,使其看起来像这样,但这会给我带来一个错误 import Route from '@ember/routing/route'; export default Route.extend({ model: function(){ }, redirect() {

我有一个余烬应用程序(版本3.14),我想转换到一个带有动态段的路线

当用户访问/projects/other时,我想重定向到/projects/other/2020 我更改了我的项目/其他路线,使其看起来像这样,但这会给我带来一个错误

import Route from '@ember/routing/route';

export default Route.extend({
    
    model: function(){
    
    },
    redirect() {
        let year_data = {
            year: '2020'
        };
        this.transitionTo('projects.other',year_data);
    }
});
这就是我的项目路线在routes.js中的样子

this.route('projects', function() {
  this.route('notable',{path: '/'});
  this.route('other', function() {
    this.route('list', {path: '/:year'});
  });
});
这些是来自谷歌浏览器控制台框的错误


错误信息非常清楚。您正在尝试重定向到没有任何动态段的
projects.other.index
路由。此外,根据,您需要传递id而不是对象。当您传递一个对象时,ember将其视为准备使用的模型。因此,您的代码应该是

this.transitionTo('projects.other.list', '2020');

我的错误是,我试图转换到/projects/other/2020,路径是projects.other.list将代码更改为
this.transitiono('projects.other.list',year\u data)
修复了此问题。同样,这只是因为我不小心没有重新检查通过对象的路由,请注意,该属性必须与动态段具有相同的名称(在本例中为:year)。谢谢你的回答。我不小心漏掉了这个清单。