首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ember.js路由

Ember.js路由
EN

Stack Overflow用户
提问于 2012-04-14 13:09:55
回答 5查看 6.5K关注 0票数 7

我正在努力寻找任何好的Ember.js路由示例。

我应该使用像this这样的插件,还是我个人喜欢this的外观

我看到有一个routes集合作为State对象的一部分,但我找不到任何如何使用它的示例。

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2012-04-14 21:18:02

编辑:由于Ember.js路由器的重大变化,此答案在1.0预发行版中已过时。MOdern版本的ember.js应该

我猜这(至少现在)是非常私人的。我喜欢亨普顿的ember routemanager。如果你需要帮助,我可以帮你。再加上他的ember-layout包,它们在一起工作得很好。

http://codebrief.com/2012/02/anatomy-of-a-complex-ember-js-app-part-i-states-and-routes/

票数 1
EN

Stack Overflow用户

发布于 2012-05-22 22:37:01

路由最近在核心Ember.js中可用,请参阅Tom Dale的blog post

核心开发人员Yehuda Katz写了一篇关于新路由功能用法的gist。这是一个很好的读物,除了路由之外,还说明了它如何与控制器集成。

为了获得基本概念,这里有一个摘自大意的代码示例:

代码语言:javascript
复制
App.Router = Ember.Router.extend({
  root: Ember.State.extend({
    index: Ember.State.extend({
      route: '/',
      redirectsTo: 'calendar.index'
    }),

    calendar: Ember.State.extend({
      route: '/calendar',

      index: Ember.State.extend({
        route: '/'
      }),

      preferences: Ember.State.extend({
        route: '/preferences'
      })
    }),

    mail: Ember.State.extend({
      route: '/mail',

      index: Ember.State.extend({
        route: '/'
      }),

      preferences: Ember.State.extend({
        route: '/preferences'
      })
    })
  })
});

// If the user navigates to the page with the URL
// www.myapp.com/, you will start in the root.calendar.index state.
// The redirection to the calendar.index state will cause the URL
// to be updated to www.myapp.com/calendar

router.transitionTo('preferences');

// URL => www.myapp.com/calendar/preferences

router.transitionTo('mail.preferences');

// URL => www.myapp.com/mail/preferences

router.transitionTo('index');

// URL => www.myapp.com/mail
票数 21
EN

Stack Overflow用户

发布于 2012-04-16 21:15:43

我在我的应用程序中使用sproutcore-routing是因为:

  • 它与ember.js
  • 配合得很好它被一些较大的ember.js应用程序使用(例如,查看travis-ci travis-ci

有关文档,请查看spoutcore-routing tests

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10151202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档