Polymer template dom-if属性

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).

转载于:https://my.oschina.net/u/2391658/blog/995726

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值