非常に単純な Web サイトに Durandal を使用しています。すべてのブラウザ タブで、ページ タイトルに「undefined|」が表示されます。アプリケーションのタイトルの前に追加されます。Durandal はどこでその値を取得して設定しますか?
タラッカー
非常に単純な Web サイトに Durandal を使用しています。すべてのブラウザ タブで、ページ タイトルに「undefined|」が表示されます。アプリケーションのタイトルの前に追加されます。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' },...
]);
ビューモデルがアクティブになったときにページ タイトルを設定できます。
activate: function (params) {
// Setting page title
params.routeInfo.caption = "My Page Title";
return true;
}
RainerAtSpirit の回答を少し修正: ルートで「名前」の代わりに「タイトル」を指定します。
router.map([
{ url: 'hello', moduleId: 'samples/hello/index', title: 'Hello World', visible: true },
{ url: 'hello/:name', moduleId: 'samples/hello/index', title: 'Examples' },...
]);