0
<link rel="import" href="../bower_components/polymer/polymer.html">
<polymer-element name="my-thing">
<script>
Polymer('my-thing', {
athing: function() { return 'hello' }
});
</script>
</polymer-element>
위에서 정의한 요소를 아래 요소에 사용하고 athing 속성에 액세스 할 수있게하려고합니다. ID 년대와다른 요소에서 메소드를 호출하려면 어떻게해야합니까?
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="./mything.html">
<polymer-element name="my-hello"">
<template>
<my-thing id="mything"></my-thing>
</template>
<script>
Polymer('my-hello', {
ready: function() {
this.$.mything.athing() // returns undefined
}
});
</script>
</polymer-element>
감사합니다. 그것은 실제로 오타였습니다. –
나는 혼란 스럽다. 이제 당신의 예제가 말한다 :'this. $. mything.athing() // undefined'를 반환한다. ... 그것은 여전히 당신이 관찰하는 것인가? –
예, 이전에 "$"를 생략했지만 예를 변경했습니다. 오타였습니다. 위의 예는 제가 관찰 한 것입니다. –