The $attrs in vue is a really useful thing in component layout. If I have a component that generates a tag a
, I could use it $attrs
to pass all of its native properties to it without needing to create a parameter for each of them.
For example, having the following component..
<div>
<a href="@Href" onclick="@OnClick" class="@Classes" style="@Styles">@Content</a>
</div>
This forces me to declare the parameters Href
, OnClick
, Classes
, Styles
, but we know that the tag a
has a lot of parameters, like target
, hreflang
, etc and not to mention other elements like a input
.
Having shown this example...
Does Blazor have any similar functionality?
Yes, it has!
For this, the new splat operator can be used , for example
Defining a parameter like the one in the previous example will cause all parameters defined in the component to be applied that do not match another existing parameter.
Use:
should render
Answer in English