zoukankan      html  css  js  c++  java
  • 链接转化为二维码

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="utf-8">
    </head>
    
    <body>
        <div id="app">
           {{message}}
           <button @click="showCode('all')">点我啊</button>
           <div id="insertCode"></div>
        </div>
    </body>
    
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./jquery.min.js"></script>
    <script src="./qrcode.js"></script>
    <script src="./qrcode.min.js"></script>
    <script>
    </script>
    <script>
        var app = new Vue({
            el: '#app',
            // str:'',
            data: {
                message: 'Hello Vue!',
                str:'',
                qrcode:''
            },
            methods: {
               showCode:function (item){
                    if (item == 'all') {
                        this.geturl('https://try.fishqc.com')
                    }
               },
                //得到url
                geturl: function (url) {
                    
                    this.str = url;
                    this.qrcode.makeCode(this.str);
                },
                getGood:function () {
                    this.qrcode=new QRCode(document.getElementById("insertCode"), {
                         120,
                        height: 120
                    });
                }
        
            },
            mounted: function() {
                this.getGood()   
            }
        })
    </script>
    
    </html>

    这里要注意的是必须要在mounted里面去调用,因为qrcodejs应该是操作dom的,所以需要dom树完全渲染出来才调用,见附件

  • 相关阅读:
    83. Remove Duplicates from Sorted List
    141. Linked List Cycle
    hdu1028 划分数
    XDU1019 阶乘因子的个数
    poj2773 容斥原理
    poj1091 容斥原理的应用
    poj1173 多重集组合数
    HDU 1465 错排问题
    poj 1496
    复习之求一个数的约束之积模一个质数
  • 原文地址:https://www.cnblogs.com/antyhouse/p/9198348.html
Copyright © 2011-2022 走看看