如何使用 Polymer 的 dom-repeat 映射数组
How do you map an array using Polymer's dom-repeat
我目前正在尝试将我拥有的字符串数组映射到其相应的对象...但找不到进行映射的方法。
我想做下面这样的事情(我知道语法不正确,但我想表达我的观点)
// user.connections ["1","2","3"]
<template is="dom-repeat" items="{{user.connections}}" as="connection"
map="isAppConnection" observe="app.id">
{{connection}} <!-- The actual object -->
</template>
<dom-module is="some-element">
<template is="dom-repeat" items="{{isAppConnection(user.connections)}}" as="connection">
{{connection}}
</template>
</dom-module>
<script>
Polymer({
is: "some-element",
properties: {user: Object},
isAppConnection: function(connections){
connections.map(e=>SomeObj[e])
},
})
</script>
我目前正在尝试将我拥有的字符串数组映射到其相应的对象...但找不到进行映射的方法。
我想做下面这样的事情(我知道语法不正确,但我想表达我的观点)
// user.connections ["1","2","3"]
<template is="dom-repeat" items="{{user.connections}}" as="connection"
map="isAppConnection" observe="app.id">
{{connection}} <!-- The actual object -->
</template>
<dom-module is="some-element">
<template is="dom-repeat" items="{{isAppConnection(user.connections)}}" as="connection">
{{connection}}
</template>
</dom-module>
<script>
Polymer({
is: "some-element",
properties: {user: Object},
isAppConnection: function(connections){
connections.map(e=>SomeObj[e])
},
})
</script>