uniapp上傳圖片轉base64碼


            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);
                }
            });
        },

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM