Commit 037de0520cb32496acc3e85b33ebb342a5eedfac

Authored by Aresn
Committed by GitHub
2 parents 5dc44ccf 6d017f5a

Merge pull request #2890 from yangdan8/patch-6

解决select-item引起的大量内存泄漏的bug
Showing 1 changed file with 10 additions and 6 deletions   Show diff stats
src/components/select/option.vue
... ... @@ -67,23 +67,27 @@
67 67 // 在使用函数防抖后,设置 key 后,不更新组件了,导致SearchLabel 不更新 #1865
68 68 updateSearchLabel () {
69 69 this.searchLabel = this.$el.textContent;
  70 + },
  71 + onSelectClose(){
  72 + this.isFocus = false;
  73 + },
  74 + onQueryChange(val){
  75 + this.queryChange(val);
70 76 }
71 77 },
72 78 mounted () {
73 79 this.updateSearchLabel();
74 80 this.dispatch('iSelect', 'append');
75   - this.$on('on-select-close', () => {
76   - this.isFocus = false;
77   - });
78   - this.$on('on-query-change', (val) => {
79   - this.queryChange(val);
80   - });
  81 + this.$on('on-select-close', this.onSelectClose);
  82 + this.$on('on-query-change',this.onQueryChange);
81 83  
82 84 const Select = findComponentUpward(this, 'iSelect');
83 85 if (Select) this.autoComplete = Select.autoComplete;
84 86 },
85 87 beforeDestroy () {
86 88 this.dispatch('iSelect', 'remove');
  89 + this.$off('on-select-close', this.onSelectClose);
  90 + this.$off('on-query-change',this.onQueryChange);
87 91 }
88 92 };
89 93 </script>
... ...