と私は、ポリマーとJSにかなり新しいんだけど、私は両方に慣れるしようとしてきました。ベースとしてthis demoを使用して、私はネオンアニメーションやボタンのクリックイベントを使用して一部のアイコンに縮小アニメーションを添付しようとしてきました。私は、ボタンを含むテンプレートを見つけることquerySelectorを使用しようとするたびに、それは常に返しません:プロパティを設定できません「_onButtonClick」ヌルのポリマーネオンアニメーション
"icon-toggle-demo.html:34 Uncaught TypeError: Cannot set property '_onButtonClick' of null"
をどんなに私はちょうどボタンがnullでないように取得することはできません変更するもの。私はここで何が欠けているのか分からない。
ボタンを含むマイファイル:
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../iron-icons/iron-icons.html">
<link rel="import" href="../icon-toggle.html">
<dom-module id="icon-toggle-demo">
<template is="dom-bind">
<style>
:host {
font-family: sans-serif;
}
;
</style>
<h3>Statically-configured icon-toggles</h3>
<button on-click="_onButtonClick">click me</button>
<icon-toggle toggle-icon="star"></icon-toggle>
<icon-toggle toggle-icon="star" pressed></icon-toggle>
<h3>Data-bound icon-toggle</h3>
<!-- use a computed binding to generate the message -->
<div><span>[[message(isFav)]]</span></div>
<!-- curly brackets ({{}}} allow two-way binding -->
<icon-toggle toggle-icon="favorite" pressed="{{isFav}}"></icon-toggle>
</template>
<script>
var scope = document.querySelector('template[is="dom-bind"]');
scope._onButtonClick = function(event) {
var node = document.querySelector('toggle-icon');
if (node) {
node.animate();
}
};
</script>
</dom-module>
ありがとうございました!これはどのように動作するかを学ぶ上で非常に重要でした。今まではドンバインドについてはわからなかった! – Taylor
@Taylor問題ありません:) – tony19