Pārlūkot izejas kodu

update 二维码

linweizeng 2 gadi atpakaļ
vecāks
revīzija
8060a152c4
1 mainītis faili ar 16 papildinājumiem un 4 dzēšanām
  1. 16 4
      src/views/component/qrcodeed.vue

+ 16 - 4
src/views/component/qrcodeed.vue

@@ -1,6 +1,6 @@
 <template>
 <template>
     <div style="height:150px">
     <div style="height:150px">
-        <div id="qrcode" ref="qrcode" class="qrCode" />
+        <div id="qrcode" ref="qrcodes" class="qrCode" />
     </div>
     </div>
 
 
 </template>
 </template>
@@ -22,17 +22,26 @@ export default {
             default: false
             default: false
         }
         }
     },
     },
+    data () {
+        return {
+            qrCode: ''
+        }
+    },
     watch: {
     watch: {
         'formData.changJingId': {
         'formData.changJingId': {
             handler () {
             handler () {
-                this.qrcode()
+                this.$nextTick(() => {
+                    this.qrcode()
+                })
             },
             },
             immediate: true
             immediate: true
 
 
         }
         }
     },
     },
     mounted () {
     mounted () {
-        // this.qrcode()
+        // setTimeout(() => {
+        //     this.qrcode()
+        // }, 500)
     },
     },
     destroyed () {
     destroyed () {
         if (window.qrTimer) {
         if (window.qrTimer) {
@@ -42,7 +51,10 @@ export default {
 
 
     methods: {
     methods: {
         qrcode () {
         qrcode () {
-            const qrcode = new QRCode('qrcode', {
+            if (this.qrCode) {
+                this.$refs.qrcodes.innerHTML = ''
+            }
+            this.qrCode = new QRCode('qrcode', {
                 width: 132,
                 width: 132,
                 height: 132,
                 height: 132,
                 text: `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0aecf99696061a3&redirect_uri=https%3A%2F%2Fwww.szjyxt.com%2F%23%2Fziliao&response_type=code&scope=snsapi_base&state=${this.formData.changJingId}#wechat_redirect`,
                 text: `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0aecf99696061a3&redirect_uri=https%3A%2F%2Fwww.szjyxt.com%2F%23%2Fziliao&response_type=code&scope=snsapi_base&state=${this.formData.changJingId}#wechat_redirect`,