我是靠谱客的博主 典雅故事,这篇文章主要介绍uniapp上传图片转base64码(PC端),现在分享给大家,希望可以做个参考。

uni.chooseImage({
    count: 9,
    success: res => {
        this.imageList = this.imageList.concat(res.tempFilePaths);
        console.log(res);
        // this.tempFilePaths = res.tempFilePaths[0];
        this.urlTobase64(res.tempFilePaths[0]);
    }
});

//转base64码
urlTobase64(url) {
    uni.request({
        url: url,
        method: 'GET',
        responseType: 'arraybuffer',
        success: res => {
            let base64 = wx.arrayBufferToBase64(res.data); //把arraybuffer转成base64
            base64 = 'data:image/jpeg;base64,' + base64; //不加上这串字符,在页面无法显示
            console.log(base64);
        }
    });
},

 

最后

以上就是典雅故事最近收集整理的关于uniapp上传图片转base64码(PC端)的全部内容,更多相关uniapp上传图片转base64码(PC端)内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(108)

评论列表共有 0 条评论

立即
投稿
返回
顶部