我有两个使用polymer 1.0.0定义的Web组件,我的问题是访问父公共API
<dom-module id="x-gallery"> <template is="dom-repeat" items="{{photos}}"> <x-photo photo="{{item}}"></x-photo> </template> </dom-module> <script> polymer({ is: 'x-gallery',... getAll: function() { return this.photos; } }); </script> <dom-module id="x-photo"> <template> <img src="{{photo.src}}"> </template> </dom-module> <script> polymer({ is: 'x-photo',properties: { photo: Object },ready: function() { // HERE --- // How Could I access the x-gallery.getAll public method? // ... } }); </script>
正如您所看到的,我想知道如何从孩子们轻松访问getAll公共方法?
我已经看到一些文档涉及基于事件的解决方案(听儿童事件),但这并不符合我的需要.除非你告诉我唯一的解决方案..
有任何想法吗?