空晓天
空晓天
  • 发布:2023-08-18 16:34
  • 更新:2024-06-25 11:22
  • 阅读:508

app 使用 plus.webview.currentWebview().draw 截图黑屏

分类:HTML5+

使用一下代码 app 截图黑屏,这是什么问题呀

/** 截屏 */  
const screenshot = () => {  
    // #ifdef APP-PLUS  
    let bitmap = new plus.nativeObj.Bitmap() // 图片对象  
    const wvs = plus.webview.currentWebview()  
    wvs.draw(bitmap, async (res) => {  
        console.log('=== ', res)  
        // 保存图片  
        const savePath = '_downloads/km-screeenshot.png'  
        bitmap.save(savePath, { overwrite: true }, () => {  
            tmpImageSrc.value = savePath  
            saveImage(savePath)  
        }, screenshotError)  

    }, screenshotError, {   
        bit: 'RGB565',  
        check: true,  
        clip: {top:'0px',left:'0px',width:'100px',height:'100px'}  
    })  
    // #endif  
}
2023-08-18 16:34 负责人:无 分享
已邀请:
喜欢技术的前端

喜欢技术的前端 - QQ---445849201

试试这个方法

bitmapFun(){  
                let _this = this  
                var pages = getCurrentPages();  
                var page = pages[pages.length - 1];  
                var bitmap = null;  
                var currentWebview = page.$getAppWebview();  
                var floatT = new Date().getTime();  
                bitmap = new plus.nativeObj.Bitmap('amway_img');  
                uni.showLoading();  
                // 将webview内容绘制到Bitmap对象中  
                currentWebview.draw(bitmap, function() {  
                    bitmap.save("_doc/m"+floatT+".jpg", {}, function(i) {  
                        console.log(i.target);//图片  

                        bitmap.clear(); //销毁Bitmap图片  
                        uni.hideLoading();  
                    }, function(e) {  
                        uni.hideLoading();  
                        console.log(JSON.stringify(e));  
                    });  
                }, function(e) {  
                    uni.hideLoading();  
                });  
            }
  • 空晓天 (作者)

    谢谢,我去试试哈

    2023-08-18 17:25

  • 喜欢技术的前端

    回复 2***@qq.com: 不客气,你的是vue3 得改改

    2023-08-18 17:28

  • 亿企查

    如果需要长截图怎么办?这个方案只能截取到可视内容

    2024-07-02 11:25

1***@qq.com

1***@qq.com

请问下,不能截二维码是什么原因

要回复问题请先登录注册