Polymer template dom-if属性

原创
2017/06/22 20:26
阅读数 162

When if becomes falsey, the stamped content is hidden but not removed from dom. When ifsubsequently becomes truthy again, the content is simply re-shown. This approach is used due to its favorable performance characteristics: the expense of creating template content is paid only once and lazily.

Set the restamp property to true to force the stamped content to be created / destroyed when the if condition changes.

简而言之,如果需要移除或新建dom则添加restamp=true属性。如下实例:

<template is="dom-if" if="{{loadDialog}}" restamp=true id="dialogTemplate">

...//中间dom

</template>

如果不添加restamp=true,则loadDialog为true/false时,中间dom只是显示(show)或隐藏(hide),添加restamp=true之后,中间dom会新建(create)或移除(destroy).

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部