gpt4 book ai didi

javascript - polymer dom-if 不会在 dom-repeat 下重新标记计算条件

转载 作者:太空宇宙 更新时间:2023-11-04 16:13:16 25 4
gpt4 key购买 nike

所以我有一个场景:

<template is="dom-repeat" items="{{objects}}" as="o" filter="{{_filter(filter)}}">
...
<template is="dom-if" if="_isHidden" restamp>
foo
</template>
...
</template>

现在,_filter函数强制重新渲染 dom-repeat 下的项目每次我的filter属性更改(因为 _filter 观察到它。这不是问题,因为它工作正常,但问题是 _hidden 函数可能会根据另一个属性(也可能会更改)返回 true 或 false,并且每当过滤器重新渲染我需要强制重新评估 _isHidden 因此隐藏或显示 dom-if 模板的内容。

有人知道我的问题是什么吗?

谢谢!

最佳答案

您还必须绑定(bind) _isHidden 属性:

<template is="dom-repeat" items="{{objects}}" as="o" filter="{{_filter(filter)}}">
...
<template is="dom-if" if="{{_isHidden}}" restamp>
foo
</template>
...
</template>

关于javascript - polymer dom-if 不会在 dom-repeat 下重新标记计算条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41286111/

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