js 屏幕截图

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>screen shot demo</title>
    <!--修改文件引入路径为你项目的路径即可-->
    <script src="./screenShotPlugin.umd.js"></script>
</head>

<body>
    <div id="app">
        <img src="./1.png">
        <div>
            截图插件文字展示
        </div>
        <br />
        <button onclick="changeScreenShot()"> 点击截图 </button>
        <p>图片展示</p>
        <img src="" alt="" id="show" >

    </div>
</body>
<script type="text/javascript">
    const changeScreenShot = async () => {
        // 截图确认按钮回调函数
        const callback = (res) => {
            const img = document.querySelector("#show");
            img.src = res.base64;
        }
        // 截图取消时的回调函数
        const closeFn = () => {
            console.log("截图窗口关闭");
        }
        new screenShotPlugin({ enableWebRtc: true, completeCallback: callback, closeCallback: closeFn });
    }
</script>



</html>

screenShotPlugin.umd.js文件这里

其他方法看这里js-screen-shot · likaia

猜你喜欢

转载自blog.csdn.net/m0_59203969/article/details/134828647