c# - 迁移到 asp.net 核心时用 taghelper 替换 @helper
问题描述
在我的应用程序框架的当前版本中,我有一个 Razor HTML @helper
,如下所示:
@helper SideMenuItem(string display, string action, string controller, string area, string faIcon)
{
<li class="@Html.IsSelected(controller, action)">
<a href="@Url.Action(action, controller, new {area})"><i class="fa @faIcon"></i> <span class="nav-label">@display</span> </a>
</li>
}
据我所知,这种语法格式已在 asp.net 核心中删除,现在首选方法是通过tag helpers。但是,我很难理解 asp.net 核心中的等价物是什么。我现在需要声明一个完整的类来获得与旧@helper
类相同的重用水平,这似乎很奇怪。我错过了什么吗?
解决方案
推荐阅读
- firebase - 资产中的配置文件,但在播放模式下仍然出错
- php - 尝试将值传递给 ISSET 条件但出现错误
- php - 如何附加具有相关下拉列表的行
- python - 无法在此数据源中查找
- javascript - 关于我遇到的关于星球大战应用程序的问题
- javascript - 获取 Google 云存储中特定目录中的所有文件和子目录
- http-live-streaming - 警告:错误的管道:URI 没有源元素
- javascript - 如何插入链接,通过 JS 代码打开 URL,而不是直接跟随 URL?
- reactjs - 使用 accessToken 和 refreshToken 进行身份验证的问题
- java - 编辑后表格视图的单元格上的值未更新