【发布时间】:2020-05-01 11:33:28
【问题描述】:
我有一个 ember 应用程序(版本 3.14),我想通过动态段转换到 Route
当用户访问 /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/2020 路线是 projects.other.list 将代码更改为
this.transitionTo('projects.other.list',year_data)解决了这个问题。再次,这只是我不小心没有重新检查路线
标签: ember.js