调包侠 之 webworker
作者:互联网
晚上回家,实装一下。。。
客户端方面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript">
var worker = new Worker("li.js");
worker.postMessage("hello server!!! webworker");
worker.onmessage = function(res){
console.log(res.data);
}
</script>
</head>
<body>
</body>
</html>
js 服务器方面
li.js
this.onmessage = function(res){
var data = res.data;
var lastData = data.toUpperCase();
this.postMessage(lastData);
}
在浏览器上访问
http://localhost/00_webworker_demo.html
浏览器 控制台 可输出
HELLO SERVER!!! WEBWORKER
标签:res,worker,调包,js,webworker,var,data 来源: https://blog.csdn.net/MENGCHIXIANZI/article/details/105215942