1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| <script> import QRCode from 'qrcode'; mounted(){ this.CreateQrcode(); }, method:{ setTimeout(() => { let dom = document.getElementById('qrcode); // 路由传参 const res = this.$route.params; const lbsid = res.id; // 二维码包含的URL 需要将URL和id做一下字符串的拼接 let url = 'http: let URL = url.concat(lbsid); let qrCode = new QRCode(dom,{ width:260, height:260, colorDark:"#000000", colorLight:"#ffffff", correctLevel: QRCode.CorrectLevel.H }); qrCode.clear(); qrCode.makeCode(URL); },100) } </script> <style lang="less" scoped> #qrcode { display: inline-block; margin-top: 6rem; img { width: 60%; height: 60%; background-color: #fff; //设置白色背景色 padding: 6px; // 利用padding的特性,挤出白边 } } </style>
|