Ember.js API (v2.11.0) 翻译 ---004.Routing---Introduction(引言)
2017-02-21 12:25
357 查看
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.
它能够处理如改变模型数据或者导向到一个新的路由的行为
引言
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.
它能够处理如改变模型数据或者导向到一个新的路由的行为
相关文章推荐
- Ember.js API (v2.11.0) 翻译 ---004.Routing---002---Defining Your Routes Edit Page(定义你的路由)
- 【cocos2d-js官方文档】二十一、v3相对于v2版本的api变动
- [Node.js] Introduction to apiCheck.js
- GOOGLE API - 翻译, 后台c# 调用前台js代码, asp.net后台调用js代码
- Node.js中REST API使用示例——基于云平台+云服务打造自己的在线翻译工具
- 翻译连载 |《你不知道的JS》姊妹篇 |《JavaScript 轻量级函数式编程》- 引言&前言
- 翻译连载 |《你不知道的JS》姊妹篇 | JavaScript 轻量级函数式编程-引言&前言
- (翻译)《Hands-on Node.js》—— Introduction
- 工作日志--微信支付整合到opensns(v2)下之jsapi支付(输入金额无刷新)
- 最高性能的javascript发布订阅系统Arbiter.js API翻译
- Yelp API(v2) with Mode.js support--handling of authentication
- Draftjs中文翻译5 - v0.10 API迁移
- Swing应用程序框架(Swing Application Framework)API绪论(JSR-296)之一(翻译)
- JS代码格式化和语法着色V2
- RFC1961中文翻译 GSS-API对SOCKS V5 的认证方法(GSS-API Authentication Method for SOCKS Version 5)
- Introduction to graphs and their data structures Section II[翻译]
- gdal的api翻译和使用经验(转自李林兄blog)
- Don’t Use the Win32 API PostThreadMessage() to Post Messages to UI Threads(翻译)
- Introduction to graphs and their data structures Section III[翻译]
- The Basics of the MMAPI for Java Developers -> Introduction to the MMAPI