簡體   English   中英

dom-bind 錯誤:未定義偵聽器方法

[英]dom-bind error: listener method not defined

我正在使用聚合物 1.0 並且在注冊方法和調用它們時遇到問題。 它在 Chrome 中運行良好,但在 Firefox 中我收到此錯誤消息:

[dom-bind::_createEventHandler]: listener method `_onCircleClick` not defined

下面這部分代碼包含在其他聚合物元素中。

<template id="main" is="dom-bind">
  <neon-animated-pages id="pages" selected="0">
    <main-page on-circle-click="_onCircleClick"></main-page>
    <detail-page on-click="_onPageClick"></detail-page>
  </neon-animated-pages>
</template>
<script>
  var template = document.querySelector('#main');

  template._onCircleClick = function (event) {
    this.$.pages.selected = 1;
  };

  template._onPageClick = function (event) {
    this.$.pages.selected = 0;
  };
</script>

我不知道為什么它在 Firefox 中不起作用。 有任何想法嗎?

如果這是自定義標簽,我認為您不應該使用 dom-bind。

而不是使用template._onCircleClick = function()嘗試_onCircleClick: function()

(function(){
        Polymer({
            is: "tag-name",
            properties: {
            },
            _onCircleClick: function() {
                this.$.pages.selected = 1;
            },
        });
    })();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM