将 html 帮助程序迁移到 ASP.NET Core

编程入门 行业动态 更新时间:2024-10-26 22:24:07
本文介绍了将 html 帮助程序迁移到 ASP.NET Core的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在将一个项目转换为 ASP.NET Core.我需要迁移大量可重用的 html 助手,但 Core 中不存在 html 助手.

I'm converting a project to ASP.NET Core. I need to migrate lots of reusable html helpers, but html helpers do not exist in Core.

有些复杂,有些简单.这是一个非常简单的例子:

Some are complex, some simple. Here's a extremely simple example:

@helper EditIcon() { <i class="glyphicon glyphicon-pencil"></i> }

请注意,这只是一个示例.

Note that this is only an example.

Point 正在为此编写一个标签助手,这是巨大的矫枉过正. 对于部分内容也是如此.视图组件也是如此.

Point is writing a tag helper for that is gigantic overkill. Same for partials. Same for view components.

我们谈论的是 Razor 的一小部分.我最好的选择是什么?

We're talking about a little snippet of Razor. What is my best option?

推荐答案

看来只有三个选项:

So, seems there are only three options:

  • 标签助手李>
  • 部分
  • 查看组件

所以没有简单的方法来迁移 Razor 代码片段,而不需要跳过障碍.

So no simple way to migrate Razor snippets, without jumping through hoops.

编辑

所以 看起来像 html helpers 毕竟可用.他们只是没有被正确记录!

So looks like html helpers are available after all. They just haven't been properly documented!

更多推荐

将 html 帮助程序迁移到 ASP.NET Core

本文发布于:2023-11-16 22:21:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607707.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   html   ASP   Core   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!