Durandal路由器在哪里设置页面标题 [英] Where does Durandal router set page title
问题描述
我正在将Durandal用于一个非常简单的网站。在我所有的浏览器选项卡中,页面标题都带有 undefined |附加在应用程序标题的前面。杜兰达尔在哪里获取和设置该值?
I am using Durandal for a very simple website. In all of my browser tabs the page title is coming up with "undefined|" appended to the front of the application's title. Where is Durandal getting and setting that value?
pthalacker
pthalacker
推荐答案
最终,Durandal的路由器插件正在设置document.title。
Ultimately Durandal's router plugin is setting the 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能够构造一个在路线对象上缺少标题属性,因此路线的设置方式可能有所不同。
Typically Durandal is able to construct a missing caption propterty on the route object, so maybe there's something different in the way the routes are set up.
https://github.com/dFiddle/dFiddle-1.2/blob/gh-pages/App/样本/shell.js#L6
router.map([
{ url: 'hello', moduleId: 'samples/hello/index', name: 'Hello World', visible: true },
{ url: 'hello/:name', moduleId: 'samples/hello/index', name: 'Examples' },...
]);
这篇关于Durandal路由器在哪里设置页面标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!