我有以下伪组件结构:
<polymer-element ...>
<parent-custom-element>
<custom-tableview-element data="{{data}}"></custom-tableview-element>
</parent-custom-element>
<script>
ready: function () {
this.data = [{ actionButtons: [{ icon: "send" , action: this.onSendAction() },
{ icon: "delete" , action: this.onDeleteAction() }]
},
{ actionButtons: [{ icon: "add" , action: this.onAddAction() },
{ icon: "edit" , action: this.onEditAction() }]]
}];
},
onSendAction : function (e, detail, sender) {
console.log("onSendAction tapped...");
},
onDeleteAction : function (e, detail, sender) {
console.log("onDeleteAction tapped...");
},
onAddAction : function (e, detail, sender) {
console.log("onAddAction tapped...");
},
onEditAction : function (e, detail, sender) {
console.log("onEditAction tapped...");
},
</script>
</polymer-element>
然后custom-tableview-element
是core-list
,paper-icon-button
如下:
<polymer-element name="custom-tableview-element">
<template>
<core-list id="list" data="{{data}}" selectionEnabled="{{selectionEnabled}}"
selection="{{selection}}" height="80" flex multi?={{multi}} style="height:400px;">
<template>
<paper-icon-button icon="{{model.icon}}"
on-tap="{{model.action}}">
</template>
</core-list>
</template>
<script>...</script>
....
是否可以通过此parent-actions
来呼叫onSendAction
,(例如onAddAction
或paper-icon-button
)?
答案 0 :(得分:0)
不可能直接从元素内部调用它,因为它封装在阴影dom中。但您可以尝试将该函数附加到全局变量,如window。