zoukankan      html  css  js  c++  java
  • 微信小程序保存图片的方法

    1、xhtml代码

    长按保存:

    <view class="img"  catchlongpress='baocun'></view>

    2、Js代码

    baocun: function (e) {
            wx.showModal({
                title: '提示',
                content: '确定要保存这张图片吗?',
                success: function (res) {
                    if (res.confirm) {
                        console.log('用户点击确定')
                        wx.getImageInfo({
                            src: 'xxxxxxx',
                            success: function (res) {
                                console.log(res);
                                var path = res.path;
                                wx.saveImageToPhotosAlbum({
                                    filePath: path,
                                    success: function (res) {
                                        console.log('图片已保存');
                                    },
                                    fail: function (res) {
                                        console.log('保存失败');
                                    }
                                })
                            }
                        });
                    } else if (res.cancel) {
                        console.log('用户点击取消')
                    }
                }
            })
        },

    详情可参考小程序文档

  • 相关阅读:
    手机自动化
    记录
    Linux 死机了怎么办
    前端源码
    LNMP环境
    PHP学习之路(一)
    py
    蜘蛛问题
    mongodb
    【HTML/XML 2】XML基础知识点总结
  • 原文地址:https://www.cnblogs.com/lamp01/p/9188756.html
Copyright © 2011-2022 走看看