Ver Fonte

fix(FamilyRelationGraph): use nextTick instead of setTimeout for timing

openhands há 3 meses atrás
pai
commit
e1ff819788
2 ficheiros alterados com 11 adições e 9 exclusões
  1. 10 8
      cfc-frontend/components/FamilyRelationGraph.vue
  2. 1 1
      cfc-frontend/main.js

+ 10 - 8
cfc-frontend/components/FamilyRelationGraph.vue

@@ -226,15 +226,15 @@ export default {
     } catch (e) {
       this.dpr = 1
     }
-    setTimeout(function() {
+    this.$nextTick(function() {
       if (self._destroyed) return
       self.updateCanvasSize()
-      setTimeout(function() {
+      self.$nextTick(function() {
         if (!self._destroyed) {
           self.initSimulation()
         }
-      }, 80)
-    }, 40)
+      })
+    })
   },
   beforeDestroy: function() {
     this._destroyed = true
@@ -723,12 +723,14 @@ export default {
       var self = this
       var cnt = this.members ? this.members.length : 0
       self.canvasHeight = Math.max(200, cnt * 90)
-      var query = uni.createSelectorQuery().in(this)
-      query.select('.family-graph-wrapper').boundingClientRect(function(rect) {
-        if (rect) {
+    uni.createSelectorQuery().in(this)
+      .select('.family-graph-wrapper')
+      .boundingClientRect(function(rect) {
+        if (!self._destroyed && rect) {
           self.canvasWidth = rect.width || 340
         }
-      }).exec()
+      })
+      .exec()
     }
   }
 }

+ 1 - 1
cfc-frontend/main.js

@@ -15,6 +15,6 @@ App.mpType = 'app'
 
 const app = new Vue({
   store,
-  ...App
+  render: h => h(App)
 })
 app.$mount()