Blazor /Pages folder required for all pages/views?

蹲街弑〆低调 提交于 2021-01-28 01:08:47

问题


Using the default Blazor helloworl app, i copied the FetchData.razor page to a separate, custom folder.

The result:

The page is not being rendered properly (the page is taking up the whole screen / the navigation menu is gone).

Question:

Do blazor pages/views must be in the /Pages folder?


回答1:


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

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.



来源:https://stackoverflow.com/questions/56266832/blazor-pages-folder-required-for-all-pages-views

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!