一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

Ember.js 设置页面标题的例子

时间:2015-02-09 编辑:简简单单 来源:一聚教程网

ember.js 原生代码中,没有根据路由设置页面标题的方法,但可以扩展。

使用 ember-cli 安装 ember-document-title :
$ ember install:npm ember-document-title

之后在代码中使用 title 即可:

App.ApplicationRoute = Ember.Route.extend({
  title: "我的应用"
});

App.UsersRoute.extend({
  title: "用户"
});

这样路由切换时,页面的标题就会自动变换。

热门栏目