How to use subfolders in the Pages and Shared folders

牧云@^-^@ 提交于 2019-12-22 08:24:26

问题


I've got a Blazor Server-Side application. It has the folders Pages and Shared out-of-the-box. Since I have a lot of components in these folders, I wanted to distribute the components into multiple subfolders for a clearer structure. But if I do this, the components are not found and are not displayed in the GUI. What am I missing? Do I have to register the routes to the new subfolders somewhere?


回答1:


You can have whatever folder structure you wish. But you will need to update your _Imports.razor with the new namespaces.

For example if you have a structure of

MyProject/Components/Forms/MyInput.razor

You would need the following in your _Imports.razor:

@using MyProject.Components.Forms;

The other option is to reference components using their fully qualified namespace:

<MyProject.Components.Forms.MyInput/>


来源:https://stackoverflow.com/questions/57112091/how-to-use-subfolders-in-the-pages-and-shared-folders

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