如何使用页面和共享文件夹中的子文件夹 [英] How to use subfolders in the Pages and Shared folders

查看:25
本文介绍了如何使用页面和共享文件夹中的子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Blazor 服务器端应用程序.它具有开箱即用的文件夹 Pages 和 Shared.由于我在这些文件夹中有很多组件,我想将组件分布到多个子文件夹中,以便更清晰的结构.但是,如果我这样做,则找不到组件,也不会在 GUI 中显示这些组件.我错过了什么?我是否必须在某处注册到新子文件夹的路由?

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?

推荐答案

你可以拥有任何你想要的文件夹结构.但是您需要使用新的命名空间更新您的 _Imports.razor.

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

例如,如果你有一个

MyProject/Components/Forms/MyInput.razor

您需要在 _Imports.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/>

这篇关于如何使用页面和共享文件夹中的子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆