🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## 捕获窗口 <details> <summary>index.html</summary> ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <div> <button id="start">开始录制</button> <button id="stop">停止录制</button> </div> <div> <video autoplay controls id="stream"></video> </div> <script> let startBtn = document.getElementById('start') let stopBtn = document.getElementById('stop') let video = document.getElementById('stream') startBtn.onclick = function() { navigator.mediaDevices.getDisplayMedia().then(stream => { video.srcObject=stream console.log(stream); }) } stopBtn.onclick = function() { video.pause(); } </script> </body> </html> ``` </details> <br/>