【发布时间】:2021-04-05 01:44:57
【问题描述】:
组件库的定义类似于
<div>Parent component</div>
@ChildContent
<div>Footer Parent component</div>
@Code {
[Parameter] public RenderFragment ChildContent{get;set;}
}
子组件是
@layout ParentComponent
<div>child component layout</div>
因此,渲染的 html 只是子元素 我们只看到
child component layout
我在谷歌上搜索并找到了一些类似this 的结果
child component layout
Panret component
child component layout
Footer Parent component
这意味着子组件被渲染了两次!
这种结构就像魅力一样在“页面”上工作!!! 如果我添加
@page "/ChildComponent"
到 ChildComponent 并导航到它,它正确呈现。 这个问题只有当我们将它用作页面的组件时才出现
【问题讨论】:
标签: .net asp.net-core razor blazor