当前位置:网站首页>uniapp app 端截屏且保存到本地
uniapp app 端截屏且保存到本地
2022-06-22 12:42:00 【艾米家的猫儿(傻钢)】
down() {
setTimeout(() => {
let pages = getCurrentPages();
let page = pages[pages.length - 1];
let ws = page.$getAppWebview();
let bitmap = new plus.nativeObj.Bitmap('drawScreen');
// 将webview内容绘制到Bitmap对象中
ws.draw(bitmap, () => {
// 保存图片到本地
bitmap.save("_doc/drawScreen.jpg", {
overwrite: true
}, res => {
console.log(res.target); // 图片地址
uni.saveImageToPhotosAlbum({
//保存图片到系统相册。
filePath: res.target, //图片文件路径
success: () => {
uni.showModal({
title: '温馨提示',
content: '保存图片成功,赶紧去转发给好友吧~',
showCancel: false,
confirmColor: "#34CE98",
confirmText: '知道了',
success: () => {
this.canSave = false;
}
})
uni.hideLoading()
},
fail: function(e) {
uni.showModal({
title: '温馨提示',
content: '保存图片失败,重新再试试~',
showCancel: false,
confirmColor: "#34CE98",
confirmText: '知道了',
success: () => {
this.canSave = false;
}
})
uni.hideLoading()
}
});
bitmap.clear(); // 清除Bitmap对象
}, error => {
console.log(JSON.stringify(error)); // 保存失败信息
uni.showModal({
title: '温馨提示',
content: '保存图片失败,重新再试试~',
showCancel: false,
confirmColor: "#34CE98",
confirmText: '知道了',
success: () => {
this.canSave = false;
}
})
uni.hideLoading()
bitmap.clear(); // 清除Bitmap对象
});
// bitmap.clear(); // 清除Bitmap对象
}, error => {
uni.showModal({
title: '温馨提示',
content: '保存图片失败,重新再试试~',
showCancel: false,
confirmColor: "#34CE98",
confirmText: '知道了',
success: () => {
this.canSave = false;
}
})
uni.hideLoading()
console.log(JSON.stringify(error)); // 绘制失败
}, {
check: true, // 设置为检测白屏
});
}, 2000)
}
边栏推荐
- Detailed installation tutorial of MySQL 8.0.29 under windows to solve the problem that vcruntime140 cannot be found_ 1.dll、plugin caching_ sha2_ password could not be loaded
- Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
- If the programmer tells the truth during the interview
- Leetcode game 297
- 定金预售的规则思路详解
- STM32F1与STM32CubeIDE编程实例-光断续传感器驱动
- SQL Server common functions
- SQL row column conversion
- Microservice test efficiency governance
- Oracle user space statistics
猜你喜欢

Detailed installation tutorial of MySQL 8.0.29 under windows to solve the problem that vcruntime140 cannot be found_ 1.dll、plugin caching_ sha2_ password could not be loaded

基于JSP的图书馆管理系统,包含源码,数据库脚本,项目运行视频教程,毕设论文撰写视频教程

Redis password modification, startup, view and other operations

“不敢去懷疑代碼,又不得不懷疑代碼”記一次網絡請求超時分析

Docker installing PostgreSQL

Acwing 241 Loulan totem (detailed explanation of tree array)

BSN发展联盟理事长单志广:DDC可为中国元宇宙产业发展提供底层支撑

openGauss数据库源码解析系列文章—— 密态等值查询技术详解

My suggestions on SAP ABAP transformation

257. Binary Tree Paths
随机推荐
Leetcode daily question 202110
“不敢去懷疑代碼,又不得不懷疑代碼”記一次網絡請求超時分析
leetcode-子序列/子串问题
微服务测试效率治理
Word skills summary
"N'osez pas douter du Code, vous devez douter du Code" notez une analyse de délai de demande réseau
Oracle's skills in dealing with inserting duplicate records
leetcode LCP 10. Binary tree task scheduling
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
Query rewriting for opengauss kernel analysis
力扣每日一练之双指针2Day9
Chapter 1 overview of naturallanguageprocessing and deep learning
HW is around the corner. Can't you read the danger message?
SSM based community garbage classification and transportation management system, high-quality graduation thesis example (can be used directly), source code, database script, project introduction and o
Views in MySQL
BSN发展联盟理事长单志广:DDC可为中国元宇宙产业发展提供底层支撑
Tasks and responsibilities of the test team and basic concepts of testing
Stephencovey's tips for efficient work for young people
268. Missing Number
定金预售的规则思路详解