Javascript事件处理程序从头开始执行所有功能

时间:2019-03-24 08:09:35

标签: javascript dom-events

我有一个非常奇怪的行为,我不明白为什么会发生

在脚本运行结束时,末尾的console.log会打印一次,然后针对每个发生的事件再次打印,并且tempOutput数组会出现3次,每次都有不同的值。

    var tempOutput = []

    if (limited) {
      var selectseries = mvc.Components.getInstance('selectseries');

      selectseries.on("change", function(event) {

          let vfx = setInterval(
            function() {
              dropSelect.classList.add('pulse-on');
              setTimeout(
                function() {
                  dropSelect.classList.remove('pulse-on')
                }, 1200
              )
            }, 2400);
          defaultTokenModel.on("change:" + dropDownTyp.tokenName, function(e) {
            if (vfx) {
              clearInterval(vfx);
              document.querySelector('#drop_arrow').style.background = ''
            }
          });
        } else {
          dropSelect.setAttribute('value', '<Select ' + label + '>')
          dropSelect.classList.add('disable')
        }
      })
    }


    console.log("how much?")
    console.log(tempOutput)

我希望看到阵列打印一次,然后一次打印“多少?”

0 个答案:

没有答案