_ViewImports.cshtml @layout仅在组件文件夹中可用

问题描述 投票:2回答:1

如何在@layout文件夹之外的_ViewImports.cshtml中使用components?我真的不喜欢按类型文件夹结构的功能,所以,我正在尝试实现这种结构:enter image description here

问题是@layout仅在文件夹名称为components时才有效

有什么办法吗?

顺便说一句:Login/Index.razor @layout的作品

blazor blazor-server-side
1个回答
2
投票

根据documentation

只要使用_RazorComponentInclude MSBuild属性将文件标识为Razor Component文件,就可以使用.cshtml文件扩展名在Razor Components应用程序中创作组件。

里面.csproj

<_RazorComponentInclude>Components\**\*.cshtml</_RazorComponentInclude>
© www.soinside.com 2019 - 2024. All rights reserved.