uniapp上传图片转base64码


         uni.chooseImage({
                count: 9,
                success: res => {
                    this.imageList = this.imageList.concat(res.tempFilePaths);
                    console.log(res);
                    // this.tempFilePaths = res.tempFilePaths[0];
                    var base64 = 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; //不加上这串字符,在页面无法显示
                    return base64
                }
            });
        }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM