HTML 中的 Blazor Razor 返回语句 [英] Blazor Razor return statement in HTML
本文介绍了HTML 中的 Blazor Razor 返回语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近继承了一个 Blazor 项目并遇到了许多类似的 .razor 文件:
一些标题文本>
@if(someCondition) {<div>很多 html 以及这里没有占用多行的内容</div>} 别的 {<div>更多的 html 占用了多行
}
我想知道是否有一种语法可以让我消除else"通过在我的if"中有一个 return 语句,隐藏在杂草中的语句;状况.含义:
一些标题文本>
@if(someCondition) {<div>很多 html 以及这里没有占用多行的内容</div>返回//只是在这里保释,而不是像我生活中的其他地方那样不得不开始另一个街区}<div>更多的 html 占用了多行
解决方案
是的.您可以使用 return;
这会结束 RenderFragment
没有绘制其他内容.
I recently inherited a Blazor project and come across many .razor files that are like:
<h1>Some header text></h1>
@if(someCondition) {
<div> lots of html and what not here taking up many lines</div>
} else {
<div> more html taking up many lines</div>
}
What I'm wondering is if there is a syntax that will allow me to eliminate the "else" statements that are hiding in the weeds, by having a return statement in my "if" condition. Meaning:
<h1>Some header text></h1>
@if(someCondition) {
<div> lots of html and what not here taking up many lines</div>
return //JUST BAIL HERE INSTEAD OF HAVING TO START AN ELSE BLOCK LIKE I DO ELSEWHERE IN LIFE
}
<div> more html taking up many lines</div>
解决方案
Yes. You can use return;
this ends the RenderFragment
no other content is drawn.
这篇关于HTML 中的 Blazor Razor 返回语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文