Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/462.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将事件从父元素传递到子元素(聚合物)_Javascript_Polymer_Listener_Event Bubbling - Fatal编程技术网

Javascript 将事件从父元素传递到子元素(聚合物)

Javascript 将事件从父元素传递到子元素(聚合物),javascript,polymer,listener,event-bubbling,Javascript,Polymer,Listener,Event Bubbling,我试图让父元素从它的子元素调用函数。在家长的脚本中,我有: _handleFunction: function() { console.log("Button Pressed!"); this.fire('send-update'); } 然后在它的孩子 listeners: { 'send-update': '_update' }, _update: function() { this.$$('#element').innerHTML = 0; } 但孩子

我试图让父元素从它的子元素调用函数。在家长的脚本中,我有:

_handleFunction: function() {
    console.log("Button Pressed!");
    this.fire('send-update');
}
然后在它的孩子

listeners: {
    'send-update': '_update'
},

_update: function() {
    this.$$('#element').innerHTML = 0;
}
但孩子没有开枪


我已经使用设计模式成功地向上传递了一个函数。是否可以使用相同的模式向下传递?

调用子元素的_update()函数的最简单方法是直接从父元素_handleFunction()调用它:

其中子元素的HTML id必须为“child”

this.$.child._update();