Vue實現長按二維碼保存到本地


<div id="qrcode" @click="aa"></div>
 
         
 methods: {
   aa(){//點擊下載二維碼保存到本地
      setTimeout(()=>{
      let myCanvas = document.getElementById('qrcode').getElementsByTagName('canvas');
      let a = document.createElement('a')
      a.href = myCanvas[0].toDataURL('image/png');
      a.download = 'qrcode';
       a.click()
         this.$message({
           showClose: true,
           message: '正在進行下載保存',
           type: 'success'
          });
      },0)
    },
 },

mounted(){
this.$nextTick(()=>{//繪制二維碼 let qrCodeContainer = document.getElementById('qrcode'); qrCodeContainer.innerHTML = ''; let qrcode = new QRCode(qrCodeContainer, { width: 180,//設置寬高 height: 180, correctLevel: 3 }); qrcode.makeCode(this.qrCode+'?idt_owner='+this.idt_owner+'&idt_area_open='+this.base_ids); this.imgUrl=this.qrCode+'?idt_owner='+this.idt_owner+'&idt_area_open='+this.base_ids//獲取二維碼地址,this.qrCode(域名)+參數
$("#qrcode").attr("title","");//清除二維碼鏈接數據顯示 }) }

 


免責聲明!

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



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