gpt4 book ai didi

javascript - polymer 1.0 : Help using dom-if

转载 作者:可可西里 更新时间:2023-11-01 02:14:11 25 4
gpt4 key购买 nike

有人可以提供一个正确实现 dom-if 的例子吗?

official documentation 没有提供正确使用的示例. (抱歉,没有直接链接。必须使用左上角的菜单并选择 dom-if)。

这是我目前所拥有的。显然,它不起作用。

<template>
...
<template is="dom-if" if="{{action}}=='Login'">
<!-- Also tried: if="{{action=='Login'}}" -->
<a href="#">Forgot password?</a>
</template>
...
</template>

最佳答案

这很麻烦,但你必须这样做:

<template is="dom-if" if="[[_actionIsLogin(action)]]">
<a href="#">Forgot password?</a>
</template>

<script>
Polymer({
...
_actionIsLogin: function(action) {
return action === 'Login';
}
...
});
</script>

显式创建返回 truefalse 的函数。

关于javascript - polymer 1.0 : Help using dom-if,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31511727/

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