uniapp分享图片(全屏截图)

仅支持APP端

 1 var pages = getCurrentPages();
 2 var page = pages[pages.length - 1];
 3 console.log(pages);
 4 var bitmap = null;
 5 // 获取当前页面 webview 的对象实例
 6 var currentWebview = page.$getAppWebview();
 7 bitmap = new plus.nativeObj.Bitmap('amway_img');
 8 // 将webview内容绘制到Bitmap对象中
 9 currentWebview.draw(bitmap, function() {
10     console.log('截屏绘制图片成功');
11     bitmap.save("_doc/a.jpg", {}, function(i) {
12         uni.saveImageToPhotosAlbum({
13             filePath: i.target,
14             success: function() {
15             bitmap.clear(); //销毁Bitmap图片
16             uni.showToast({
17                 title: '保存图片成功',
18                 mask: false,
19                 duration: 1500
20             });
21     }
22     });
23     }, function(e) {
24 console.log('保存图片失败:' + JSON.stringify(e));
25     });
26 }, function(e) {
27     console.log('截屏绘制图片失败:' + JSON.stringify(e));
28 });
原文地址:https://www.cnblogs.com/chenghuayike/p/14950518.html