我正在将一个项目转换为ASP.NET Core.我需要迁移许多可重复使用的html helper,但是html helper在Core中不存在.
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> }请注意,这仅是示例.
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:
- 标记助手
- 部分
- 查看组件
- tag helpers
- partials
- view components
因此,没有简单的方法来迁移Razor片段,而不会跳过箍.
So no simple way to migrate Razor snippets, without jumping through hoops.
编辑
所以看起来像 html帮助器毕竟可用.他们只是没有被正确记录!
So looks like html helpers are available after all. They just haven't been properly documented!
更多推荐
将HTML助手迁移到ASP.NET Core
发布评论