1.0 中的条件属性
Conditional attributes in 1.0
是否可以在 Polymer 1.0 中使用 conditional attributes?
我试图在 the migration guide and also in Road to polymer 中找到它,但没有成功。
我知道在 Polymer 1.0 中有一个新的 conditional template,但我不想重复我的代码。
所以在 0.5 版本中我们可以有类似的东西:
<input readonly?={{my-boolean-expression}} (...)>
而且,在 1.0 中,我们应该使用模板来完成吗?
<template is="dom-if" if="{{my-boolean-expression}}">
<input readonly (...)>
</template>
<template is="dom-if" if="!{{my-boolean-expression}}">
<input (...)>
</template>
查看文档 here。
您要做的是:
<input readonly$="{{my-boolean-expression}}">
是否可以在 Polymer 1.0 中使用 conditional attributes? 我试图在 the migration guide and also in Road to polymer 中找到它,但没有成功。
我知道在 Polymer 1.0 中有一个新的 conditional template,但我不想重复我的代码。
所以在 0.5 版本中我们可以有类似的东西:
<input readonly?={{my-boolean-expression}} (...)>
而且,在 1.0 中,我们应该使用模板来完成吗?
<template is="dom-if" if="{{my-boolean-expression}}">
<input readonly (...)>
</template>
<template is="dom-if" if="!{{my-boolean-expression}}">
<input (...)>
</template>
查看文档 here。
您要做的是:
<input readonly$="{{my-boolean-expression}}">