我无法用路由配置中指定的视图端口正确填充布局视图。我有一个路由“styleguide”,它应该使用“sidebar”布局,用“sidebar.html”填充“sidebar”路由器视图,用“content.ts/html”填充“content”路由器视图。
应用程序ts
export class App {
configureRouter(config: RouterConfiguration, router: Router) {
config.map([{
route: "styleguide",
name: "styleguide",
layoutView: "layout/sidebar.html",
viewPorts: {
sidebar: { moduleId: "styleguide/sidebar.html" },
content: { moduleId: "styleguide/index" },
}
}]);
}
}
应用程序.html
<template>
<router-view layout-view="layout/default.html"></router-view>
</template>
layout/default.html格式
(本例中未使用)
<template>
<router-view></router-view>
</template>
布局/sidebar.html
<template>
<router-view name="sidebar"></router-view>
<router-view name="content"></router-view>
</template>
样式向导/sidebar.html
<template>
SIDEBAR!!
</template>
样式向导/索引.ts
export class Index { }
样式向导/index.html
<template>
CONTENT
</template>
问题:
-
“在styleguide/sidebar.html的视图中找不到路由器视图。”——尽管我指定了路由器视图名称等。
-
我有另一条路线没有指定
layoutView
,因此使用默认值。只有当我更换
router-view
layout/default.html中的元素
slot
是的。我试图在两个布局中使用插槽,但侧边栏布局给了我相同的错误。