【发布时间】:2017-12-03 02:39:21
【问题描述】:
所以我想从子元素调度自定义事件。
<dom-module id="layout-dashboard">
<template>
<style></style>
</template>
<script>
class LayoutDashboard extends Polymer.Element {
connectedCallback() {
this.dispatchEvent(new CustomEvent('kick-start', {detail : {}, bubble: true, composed : true}))
}
}
</script>
</dom-module>
然后处理来自父级的事件。
<dom-module id="layout-parent">
<template>
<style></style>
<layout-dashboard on-kick-start="handleKick"></layout-dashboard>
</template>
<script>
class LayoutParent extends Polymer.Element {
handleKick(){
console.log("test");
}
}
</script>
</dom-module>
知道为什么handleKick() 没有被执行吗?
【问题讨论】:
标签: polymer polymer-2.x