简体   繁体   中英

How to use Html Helper methods in .razor file in Blazor

I recently started learning Blazor in .net core and I noticed I couldn't use the HTML Helper methods in the.razor file.Is there something I'm missing? I keep getting an error like "the name Html does not exist in the context".

What do I do?

You cannot use @helper directive anymore, you can create a Nested components Shared\Heading.razor and call it in the same razor component or other pages.

<h1 style="font-style:@headingFontStyle">Heading Example</h1>
<Heading />
@code {
    private string headingFontStyle = "italic";
}

or

@page "/heading-example"

<Heading />

See this document here for more details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM