HtmlTargetElement 属性中的 Attributes 属性有何用途

Pet*_*ner 3 c# asp.net asp.net-mvc tag-helpers

在 asp.net core 标记帮助器上设置属性的方式如下:

[HtmlTargetElement("test1",Attributes = "make",ParentTag = "myparent")]
Run Code Online (Sandbox Code Playgroud)

我不明白语法Attributes = "make"

我知道 Attributes 是一个传递到构造函数中的字符串HtmlTargetElement,但我没有得到的是该= "make"部分。如果这是我现在的方法的调用列表,则意味着 make 是传入 null 的值,但当它位于调用方法端时我不明白它。

属性中的 Attributes 属性有何用途HtmlTargetElement

Str*_*ake 5

HtmlTargetElement属性用于指定 TagHelper 在确定匹配时要使用的附加条件。Attributes 属性指定 html 元素必须包含要匹配的值。属性:

[HtmlTargetElement("test1",Attributes = "make")]``
Run Code Online (Sandbox Code Playgroud)

将匹配以下元素:

<test1 make></test1>
Run Code Online (Sandbox Code Playgroud)

另请记住,您可以用多个[HtmlTargetElement]属性修饰一个类以产生逻辑“或”。

有关更多示例,请参阅

有关官方文档,请HtmlTargetElement.Attributes参阅此处