Durandal路由器在哪里设置页面标题
Where does Durandal router set page title
我正在使用Durandal为一个非常简单的网站。在我所有的浏览器选项卡中,页面标题都出现了"未定义|"附加到应用程序标题的前面。Durandal是从哪里获得并设定这个值的?
pthalacker
最终Durandal的路由器插件正在设置document.title.
https://github.com/dfiddle/dfiddle - 1.2/- blob/gh pages/app/durandal/plugins/router.js # L254
onNavigationComplete: function (routeInfo, params, module) {
if (app.title) {
document.title = routeInfo.caption + " | " + app.title;
} else {
document.title = routeInfo.caption;
}
},...
通常Durandal能够在route对象上构造一个缺失的标题属性,所以可能路由的设置方式有所不同。
https://github.com/dfiddle/dfiddle - 1.2/- blob/gh pages/app/samples/shell.js # 16种
router.map([
{ url: 'hello', moduleId: 'samples/hello/index', name: 'Hello World', visible: true },
{ url: 'hello/:name', moduleId: 'samples/hello/index', name: 'Examples' },...
]);
您可以在视图模型被激活时设置页面标题:
activate: function (params) {
// Setting page title
params.routeInfo.caption = "My Page Title";
return true;
}
在Durandal 2.1.0中替换页面标题
(如果你想让页面标题不同于路由的最后一层)
对RainerAtSpirit的回答做了一个小修改:在路由中指定'title'而不是'name'。
router.map([
{ url: 'hello', moduleId: 'samples/hello/index', title: 'Hello World', visible: true },
{ url: 'hello/:name', moduleId: 'samples/hello/index', title: 'Examples' },...
]);
相关文章:
- React组件-设置页面标题
- 如何在自动完成时设置属性标题
- 是否可以像在$routeProvider中一样在 Angular AMD 中设置页面标题
- 如何在动态树标题中的输入字段上设置焦点
- 设置PDF页面的浏览器标题
- Ext JS 5.1:当可折叠为true时,无法对面板进行标题设置
- 使用javascript设置html页面的标题
- 正在为禁用的输入设置标题属性
- 如何打开jQuery对话框并将其标题自动设置为HTML标记中的属性
- 如何在dgrid中设置列内容的样式,而不设置列标题的样式
- 设置 Jquery 对话框标题栏样式
- 为HTML文本区域设置标题属性的样式
- jQuery ticker - 如何为 #ticker 标题设置 URL
- H1 标题设置不正确
- AG-Grid 将列标题设置为复选框,然后执行全选或取消全选列,而不是仅组
- MVC4引导JQuery-将下拉标题设置为所选项目
- 在JSP中将按钮标题设置为bean消息
- 将HTML中的按钮标题设置为非格式化文本
- Google 日历标题设置为“无显示”
- 如何为我的d3图表标题设置文本颜色