2015-07-13 55 views
2

是否可以在Polymer 1.0中使用conditional attributes? 我試圖在the migration guide以及Road to polymer中找到它,但沒有成功。1.0中的條件屬性

我知道在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> 

回答

7

查看文檔here

什麼,你會想要做的是:

<input readonly$="{{my-boolean-expression}}">