如何将一个值传递给Glazor组件中的标记内容?
我正在调用WebAPI获取HTML页面代码。 我还使用共享组件,其中将此代码作为育儿传递:
<div>
@ChildContent
</div>
@code {
[Parameter]
public RenderFragment ChildContent { get; set; }
}
我称为API,在我的父组件中,我以育儿代码传递代码:
<SharedEmailTemplate>
@TemplateCode
</SharedEmailTemplate>
请取消此操作,直到一切正常。我可以显示组件,所有HTML标记都可以使用。
但是在我的html中,我使用的是要根据我的输入更改的占位符:
{{{message}}}
是否有没有使用JavaScript在Blazor中做到这一点的?
I am calling WebApi to GET Html code of page.
I also use a SharedComponent where I pass this code as ChildContent:
<div>
@ChildContent
</div>
@code {
[Parameter]
public RenderFragment ChildContent { get; set; }
}
Afer I call the API, in my parent component I pass the code as ChildContent:
<SharedEmailTemplate>
@TemplateCode
</SharedEmailTemplate>
Untill this everything works fine. I can display the component, all of the HTML markups works.
But in my HTML I'm using a placeholder that I want to changed based on my input:
The message is: {{ message }}
Is there any way to do that in Blazor without using JavaScript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的意思是 - html只是文本。因此,请使用C#的许多字符串方法之一来替换文本。
https:/ en-us/dotnet/api/system.string?view = net-6.0
I mean-- html is just text. So use one of C#'s many string methods for replacing the text.
https://learn.microsoft.com/en-us/dotnet/api/system.string?view=net-6.0