gpt4 book ai didi

html - 检查 meteor 模板中的空值

转载 作者:太空狗 更新时间:2023-10-29 15:38:35 25 4
gpt4 key购买 nike

我正在使用 meteor 。我有一个看起来像这样的模板,

<template name="SearchAct">
{{#each SearchPerson}}
<div class="result"><!--This is one search result box-->
<div class="resultContent">
<img src={{payload.pic_square}} alt="profile photo" class="floatLeft" />
<p>{{payload.uid}}</p>
<span class="floatLeft">
{{payload.first_name}}
<br/>
{{payload.last_name}}
</span>
<input type="checkbox" class="floatRight" />
<h4>Tennis</h4>
<span class="age_location">
{{#if payload.birthday}}
{{payload.birthday}},
{{/if}}
{{#if payload.sex}}
{{payload.sex}}
{{/if}}
<br/>
{{#if payload.hometown_location}}
{{payload.hometown_location.city}},
{{payload.hometown_location.state}},
{{payload.hometown_location.country}}
{{/if}}
</span>
<div class="line"></div>
<a href="#" class="clear" onclick="renderProfile({{payload.uid}});">See Their Details</a>
</div><!-- End of resultContent-->
</div><!-- End of result box-->
{{/each}}
</template>

现在我想检查 {{payload.birthday}} 的空值。在这里,如果我得到 null 值,我想显示一条消息。我如何检查 null 值?

最佳答案

我想你只需要一个{{else}}:

<span class="age_location">
{{#if payload.birthday}}
{{payload.birthday}}
{{else}}
No birthday found
{{/if}}
</span>

关于html - 检查 meteor 模板中的空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11580422/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com