vue.js顯示base64string圖片


昨天在vue.js項目中,產生彩色二維碼,並顯示出來。

如這個樣子:

 

敢用手機掃一掃? 哈哈,這個二維碼只是本博客http://insus.cnblogs.com鏈接而已。

 

代碼簡單:

 

 

<div id="test">
        <img :src="'data:image/png;base64,'+ qrcode"/>       
    </div>
HTML Source Code

 

var vue_content = new Vue({
            el: '#test',
            data() {
                return {
                    qrcode: null
                }
            },
            mounted() {
                axios
                    .get('/api/BC/GetColorQrCode')
                    .then(response => (
                        this.qrcode = response.data)
                    )
                    .catch(function (error) {
                        console.log(error);
                    });
            }
        })
JavaScript Source Code

 


免責聲明!

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



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