【问题标题】:Catch-all route is getting priority over star route in ember在 ember 中,Catch-all 路线优先于明星路线
【发布时间】:2013-10-10 10:42:42
【问题描述】:

我有一个路由可以捕获所有丢失的路由并呈现 404 样式的页面。我想创建一个匹配任何以“/browse/”开头的 url 的路由,例如“/browse/shoes/red”。这似乎是正确的方法:

App.Router.map(function() {
  this.route('browse', { path: '/browse/*fields' });
  this.route('missing', { path: '/*badPath' });
});

但是,ember 的 RouteRecognizer 始终会在浏览路线上选择丢失的路线。 (这样做的逻辑在 route-recognizer.js 的 sortSolutions 中。)这是 Ember 中的错误吗?是否有正确的方法来使用 glob 路由并且仍然有 404 处理程序?

顺便说一句,我可以为浏览创建一个资源,而不是像这样将其设为路由:

App.Router.map(function() {
  this.resource('browse', { path: '/browse' }, function() {
    this.route('baz', {path: '/*'});
  });
  this.route('missing', { path: '*' });
});

这仍然有同样的问题。

【问题讨论】:

    标签: ember.js ember-router


    【解决方案1】:

    我认为这一定是一个错误......

    这是一个 JSBin:http://jsbin.com/ucanam/1403/edit

    在这里您可以看到它按预期直接进入“失踪”路线:

    http://jsbin.com/ucanam/1403#/some/random/stuff

    直接进入“浏览”路线的尝试失败:

    http://jsbin.com/ucanam/1403#/browse/test/stuff

    【讨论】:

    猜你喜欢
    • 2012-09-22
    • 2016-07-03
    • 1970-01-01
    • 2014-04-18
    • 2014-03-04
    • 1970-01-01
    • 1970-01-01
    • 2014-05-23
    • 1970-01-01
    相关资源
    最近更新 更多