实现嵌套布局后,我遇到了渲染包含网格的组件的问题。分析表明它存在于 html 中,但它具有显示块属性,并且网格永远不可见。
我读了类似的问题(Vaadin 14 - Grid not Displaying/Populate When Useed in Nested Layout),但那里列出的建议没有给我带来任何结果。
这是我的代码:
主布局.kt:
@Theme(value = Material::class, variant = Material.DARK)
class MainLayout : Composite<Div>(), RouterLayout {
//Component to delegate content through.
private val mainContent: Div = Div()
private val layout = VerticalLayout(
Span("from MainLayout top"),
mainContent,
Span("from MainLayout bottom"))
override fun showRouterLayoutContent(hasElement: HasElement) {
Objects.requireNonNull(hasElement)
Objects.requireNonNull(hasElement.element)
mainContent.removeAll()
mainContent.element.appendChild(hasElement.element)
}
init {
content.add(layout)
}
}
Run Code Online (Sandbox Code Playgroud)
LayoutWithMenuBar.kt:
@ParentLayout(value = MainLayout::class)
class LayoutWithMenuBar : Composite<Div>(), RouterLayout {
private val …Run Code Online (Sandbox Code Playgroud)