代码之家  ›  专栏  ›  技术社区  ›  Sticky

EmberJS嵌套子例程自定义索引路径未按预期工作

  •  1
  • Sticky  · 技术社区  · 8 年前

    one of the Ember Guides on routing

    Router.map(function() {
      this.route('about');
      this.route('dashboard', function() {
        this.route('index', { path: '/dashboard/calendar'});
        // ^should direct all dashboard index requests to dashboard/calendar right?
        // setting path = '/calendar' also doesn't work
    
        this.route('calendar');
        this.route('daily-journal');
      });
    });
    

    然而,当我加载时 http://localhost:3000/dashboard enter image description here

    1 回复  |  直到 8 年前
        1
  •  1
  •   Sticky    7 年前

    https://guides.emberjs.com/v2.14.0/routing/redirection/

    你只需要在你的仪表板索引路径中放一些东西

    import Ember from 'ember';
    
    export default Ember.Route.extend({
      beforeModel() {
        this.transitionTo('dashboard.calendar');
      }
    });