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