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/>