有人可以请提供一个正确实施dom-if
的例子吗?聚合物1.0:帮助使用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>
这很有帮助,因为它让我思考了一种必要的方法。所以,upvoted!但不能接受,因为这个特定的代码不起作用。随意修改它!我会。谢谢! =] – Mowzer
另外,我不认为你可以将一个参数传递给这样的函数?你可以吗? [看到这个问题](http://stackoverflow.com/questions/31441401/polymer-1-0-is-there-a-way-to-pass-an-argument-to-a-polymer-function-from-一个-AT)。 – Mowzer
如果将它们声明为属性,则可以将参数传递给计算的绑定。在[文档](https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#annotated-computed)中,它表示“参数可以是相关属性或字符串或数字文字。” – Maria