所有页面/视图都需要Blazor/Pages文件夹? [英] Blazor /Pages folder required for all pages/views?
问题描述
使用默认的Blazor helloworl应用程序,我将FetchData.razor页面复制到了一个单独的自定义文件夹中.
Using the default Blazor helloworl app, i copied the FetchData.razor page to a separate, custom folder.
结果:
页面显示不正确(页面占用了全屏/导航菜单消失了.
The page is not being rendered properly (the page is taking up the whole screen / the navigation menu is gone).
问题:
blazor页面/视图必须位于/Pages文件夹中吗?
Do blazor pages/views must be in the /Pages folder?
推荐答案
您可以随意将组件放置在所需的任何文件夹中,而 Pages
文件夹正是模板随附的文件夹.但是您会注意到,在默认模板中, Pages
文件夹中有一个名为 _Imports.razor
的文件,其中包含以下内容:
You are free to put components in whatever folders you wish, the Pages
folder is just what comes with the template. But you will notice in the default templates, the Pages
folder has a file called _Imports.razor
which contains the following:
@layout MainLayout
这意味着 Pages
文件夹中的所有组件都会自动应用 MainLayout
.如果您已将组件移动到另一个文件夹,则需要将以上行复制到您的组件,或者将 _Imports.razor
复制到新目录中.
This means all components in the Pages
folder automatically get the MainLayout
applied. If you've moved your component to another folder you will need to either copy the above line to your component or copy the _Imports.razor
into your new directory.
这篇关于所有页面/视图都需要Blazor/Pages文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!