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 生日广州男生祝福语简短