Ember.js API (v2.11.0) 翻译 ---004.Routing---Introduction(引言)

来源:互联网 发布:centos6 搭建php环境 编辑:程序博客网 时间:2024/06/16 10:53
Introdution

引言


Imagine we are writing a web app for managing a blog. At any given time, we should be able to answer questions like What post are they looking at? and Are they editing it? In Ember.js, the answer to these questions is determined by the URL.
假如我们开发一个管理博客的Web应用,那么在任何时候,我们都应该知道正在查看的博客的是哪一篇;别人能否编辑他,这些问题在Ember中是通过URL来决定的

The URL can be set in a few ways:
URL设定的集中方式如下:
The user loads the app for the first time.
应用在加载时设定

The user changes the URL manually, such as by clicking the back button or by editing the address bar.

用户通过点击浏览器的返回按钮或者编写地址栏修改

The user clicks a link within the app.

用户点击应用中的链接

Some other event in the app causes the URL to change.
应用中某些事件引起的URL变化

Regardless of how the URL becomes set, the Ember router then maps the current URL to one or more route handlers. A route handler can do several things:
不管URL如何变化,Ember的路由器都能映射当前路由对应的一个或多个路由模板,并且路由处理程序都将去做下面的几件事:

It can render a template.
渲染一个模板

It can load a model that is then available to the template.
加载一个模型数据并且提供给模板

It can redirect to a new route, such as if the user isn't allowed to visit that part of the app.
当用户不允许访问应用中的某些内容是,它能够重定向到一个新的路由

It can handle actions that involve changing a model or transitioning to a new route.
它能够处理如改变模型数据或者导向到一个新的路由的行为
0 0