我使用iron-ajax和铁列表,对于铁图像,我需要将文本连接到具有{{item.path}}
的图像源
我试过这种方式
<iron-image style="width:80px; height:80px;" sizing="cover" src="http://mydomain/{{item.path}}.jpg" preload></iron-image>
但我没有加载任何图像,在检查列表项时,它不会插入来自json数据的图像路径。
src="http://mydomain/{{item.path}}.jpg"
连接上述
的方法是什么?本身src="{{item.path}}"
我看到了检查项目时的路径
由于
答案 0 :(得分:3)
Polymer 1.0中尚不支持字符串插值。您需要使用computed binding。
例如:
<dom-module id="your-tag">
<template>
<iron-image
style="width:80px; height:80px;"
sizing="cover"
src$="{{_getImagePath(item.path)}}"
preload></iron-image>
</template>
<script>
Polymer({
is: "your-tag",
_getImagePath: function(url) {
return 'http://mydomain/' + url + '.jpg';
}
});
</script>
</dom-module>
我已经回答了类似的问题here。
答案 1 :(得分:0)
我想你忘了申报item.path
你应该 Polymer({item.path:“/ set / your / path”});答案 2 :(得分:0)
我认为这个例子可以解决你的问题:
private Set<AccountType> ADMIN_ACCOUNT_TYPES = new HashSet<AccountType>() {{
add(AccountType.LOCAL_ADMIN);
add(AccountType.GLOBAL_ADMIN);
add(AccountType.SECURITY_ADMIN);
}};
public boolean isAdmin(AccountType t) {
return ADMIN_ACCOUNT_TYPES.contains(t);
}
然后您可以按以下方式使用:
function(myPath) {
return 'http://mydomain/' + myPath + ".jpg";
}
您还可以查看here以获得进一步调查和更全面的示例。