为什么是undefined 我传参不太懂

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

</head>

<body>

<div>

<span id="list1"></span><span id="list2"></span>

<button onclick="firstWorker()">star</button>

</div>

<script type="text/javascript">

var w;

firstWorker = function() {

if(typeof Worker !== "undefined") {

w = new Worker("count.js");

}

w.onmessage = function(event) {

document.getElementById("list1").innerHTML = event.data.input;

document.getElementById("list2").innerHTML = event.data.result;


}

}

</script>

</body>

</html>

count.js:///////////////////////////////////////////////////////////////

var i = 0;

var arr = new Array();


arr[0] = 0;

arr[1] = 1;


function countNum() {

i++;

postMessage({input:i,result:i+1});

if(i < 10){

setTimeout("countNum()",1000);

}

}


countNum();


yuqingzhijie3596863
浏览 1451回答 1
1回答

yuqingzhijie3596863

已解决
打开App,查看更多内容
随时随地看视频慕课网APP