aurelia 有条件地添加或删除HTML元素
示例
与show.bind使用时不同,if.bind如果提供的绑定值是,则元素将从页面中删除;如果值为,则将元素false添加到页面中true。
export class MyViewModel {
isVisible = false;
}<template>
<div if.bind="isVisible"><strong>If you can read this, I am still here.</strong></div>
</template>分组元素
有时可能需要一次性添加或删除整组元素。为此,我们可以使用<template>元素来显示或隐藏其他元素,而不需要像DIV这样的占位符元素。
export class MyViewModel {
hasErrors = false;
errorMessage = '';
}<template if.bind="hasErrors">
<i class="icon error"></i>
${errorMessage}
</template>
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短