简体   繁体   English

JavaScript - 未捕获的类型错误:无法设置未定义的属性

[英]JavaScript - Uncaught TypeError: Cannot set property of undefined

I keep getting Uncaught TypeError: Cannot set property 'onaudioprocess' of undefined at (index):144.我不断收到 Uncaught TypeError: Cannot set property 'onaudioprocess' of undefined at (index):144。 Every time when I use the setTimeout I get the error.每次使用 setTimeout 时都会出现错误。

 setTimeout(function(){
  setupAudioNodes();
  loadSound("lecture10.mp3");
}, 3000);



javascriptNode.onaudioprocess = function() {

    //get input as web param.
    var param = window.location.search.substring(1);
    //console.log(param);
    var res = param.split("%20");

    // get the average for the first channel
    var array =  new Uint8Array(analyser.frequencyBinCount);
    analyser.getByteFrequencyData(array);
    var average = getAverageVolume(array);

    if(average < 25.0){
      if(n > res.length-1){return;}
      console.log("First Channel : " + average);
      console.log(context.currentTime);
      //document.write(parseInt(context.currentTime));
      document.write(res[n++] + " ");
      //document.getElementById('title').innerHTML = "ssss " ;
    }

}

我认为您可能在 setupAudioNodes() 中定义了 javascriptNode [意味着该节点仅在超时时间 3 秒后可用,直到该时间节点未定义],如果是这样,在 setupAudioNodes() 中移动以下行应该可以解决问题。

javascriptNode.onaudioprocess = function() { //... }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JavaScript Uncaught TypeError:无法设置未定义的属性“ -1” - JavaScript Uncaught TypeError: Cannot set property '-1' of undefined Javascript Uncaught TypeError:无法设置未定义的属性 - Javascript Uncaught TypeError: Cannot set property of undefined Javascript 函数错误未捕获的类型错误:无法设置未定义的属性“目标” - Javascript function error Uncaught TypeError: Cannot set property 'target' of undefined Uncaught TypeError:无法在2D数组(JavaScript)上设置undefined的属性“ 0” - Uncaught TypeError: Cannot set property '0' of undefined on 2D array (JavaScript) Uncaught TypeError:无法设置未定义JavaScript的属性“ width” - Uncaught TypeError: Cannot set property 'width' of undefined, javascript Uncaught TypeError:无法设置未定义javascript的属性“ backgroundColor” - Uncaught TypeError: cannot set property 'backgroundColor' of undefined javascript Javascript:未捕获的TypeError:无法设置未定义的属性“ className” - Javascript: Uncaught TypeError: Cannot set property 'className' of undefined Javascript | 未捕获的TypeError:无法设置未定义的属性“颜色” - Javascript | Uncaught TypeError: Cannot set property 'color' of undefined javascript:未捕获的TypeError:无法读取未定义的属性“ set” - javascript: Uncaught TypeError: Cannot read property 'set' of undefined Javascript滑块:未捕获的TypeError:无法设置未定义的属性&#39;className&#39; - Javascript slider: Uncaught TypeError: Cannot set property 'className' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM