识别二维码、生成二维码

最近的项目中使用到了识别二维码和生成二维码,都是用JS生成的,应用在了移动端,在网上搜罗了许多进行验证,下面是我在项目中应用的:

识别二维码

1.第一种,压缩包:https://pan.baidu.com/s/1WN49BKFM6WiNHOV4T-wDAQ
github:https://github.com/LazarSoft/jsqrcode
2.第二种:github:https://github.com/dwa012/html5-qrcode
(参考:https://blog.csdn.net/qq449736038/article/details/80771947)

生成二维码

1.第一种:https://pan.baidu.com/s/1ZfvvbtoXKrOjQRMLS5QoUg
github:https://github.com/LIGuoxiang/QRCode (参考:https://blog.csdn.net/qq449736038/article/details/80771947)
2.VUE 中使用 (参考:https://blog.csdn.net/qq449736038/article/details/80771947)

npm install qrcode
<template>
    <div>
        <div id='code'></div>
        <canvas id="canvas"></canvas>
    </div>
</template>
<script>
    import QRCode from 'qrcode'
    export default{
        data(){
            return {
                codes:''
            }
        },
        mounted(){
            this.useqrcode();
        },
        methods:{
            useqrcode(){
                var canvas = document.getElementById('canvas')
                QRCode.toCanvas(canvas, 'http://www.baidu.com', function (error) {
                    if (error) {
                        console.error(error) 
                    }
                    console.log('success!');
                })
            }
        },
        components: {
            QRCode: QRCode
        }
    }
</script>

猜你喜欢

转载自blog.csdn.net/github_37125043/article/details/80867719
今日推荐