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

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.
它能夠處理如改變模型數據或者導向到一個新的路由的行爲
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章