gpt4 book ai didi

javascript - Durandal路由器在哪里设置页面标题

转载 作者:行者123 更新时间:2023-11-29 09:53:46 24 4
gpt4 key购买 nike

我在一个非常简单的网站上使用 Durandal。在我所有的浏览器选项卡中,页面标题都带有“undefined|”附加到应用程序标题的前面。 Durandal 从哪里获取和设置该值?

苯丙胺

最佳答案

最终 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 能够在路由对象上构建一个缺失的标题属性,因此路由的设置方式可能有所不同。

https://github.com/dFiddle/dFiddle-1.2/blob/gh-pages/App/samples/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' },...
]);

关于javascript - Durandal路由器在哪里设置页面标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16846082/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com