3 changed files with 41 additions and 0 deletions
@ -0,0 +1,27 @@ |
|||
|
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|||
<title>EventSource测试</title> |
|||
</head> |
|||
<body> |
|||
<div>EventSource测试</div> |
|||
<ul></ul> |
|||
<script> |
|||
console.log("enventsource") |
|||
//这里填写要链接的地址 |
|||
var evtSource = new EventSource('/real/psflist?page=1&limit=10'); |
|||
evtSource.addEventListener('message',function(evt){ |
|||
console.log(evt) |
|||
document.querySelector("ul").innerHTML+=("<li>"+JSON.parse(evt.data).message+"</li>") |
|||
}) |
|||
// evtSource.onmessage=(evt)=>{ |
|||
// console.log(evt.data) |
|||
// document.querySelector("ul").innerHTML+=("<li>"+JSON.parse(evt.data).message+"</li>") |
|||
// //console.log(e.data) |
|||
// } |
|||
</script> |
|||
</body> |
|||
</html> |
|||
Loading…
Reference in new issue