📜  EmberJS-路由器

📅  最后修改于: 2020-10-25 11:01:31             🧑  作者: Mango


路由器是EmberJs的核心功能,它将URL转换为一系列模板并表示应用程序的状态。Ember使用路由器将URL映射到路由处理程序。路由器将当前URL与其他路由匹配,这些路由用于加载数据,显示模板和设置应用程序状态。

路由处理程序执行一些操作,例如-

  • 它提供了模板。

  • 它定义了模型,并且模板可以访问它。

  • 如果没有用户访问应用程序特定部分的权限,则路由器将重定向到新路由。

下表列出了Ember.js中的不同路由器及其描述-

S.No. Types & Description
1 Defining Routes

The router matches the current URL with routes responsible for displaying template, loading data and setting up an application state.

2 Specifying a Route’s Model

To specify a routes model, you need a template to display the data from the model.

3 Rendering a Template

The routes are used to render the external template to the screen.

4 Redirecting

It is a URL redirection mechanism that redirects the user to a different page when the requested URL is not found.

5 Preventing and Retrying Transitions

The transition.abort() and transition.retry() methods can be used to abort and retry the transition respectively during a route transition.

6 Loading/Error Substates

Ember router provides information of a route loading and errors which occur when loading a route.

7 Query Parameters

Query parameters come into view at the right side of the “?” mark in a URL represented as optional key-value pairs.

8 Asynchronous Routing

Ember.js router has the ability to handle complex async logic within an application by using asynchronous routing.