Commit 037de0520cb32496acc3e85b33ebb342a5eedfac
Committed by
GitHub
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,23 +67,27 @@ | ||
67 | // 在使用函数防抖后,设置 key 后,不更新组件了,导致SearchLabel 不更新 #1865 | 67 | // 在使用函数防抖后,设置 key 后,不更新组件了,导致SearchLabel 不更新 #1865 |
68 | updateSearchLabel () { | 68 | updateSearchLabel () { |
69 | this.searchLabel = this.$el.textContent; | 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 | mounted () { | 78 | mounted () { |
73 | this.updateSearchLabel(); | 79 | this.updateSearchLabel(); |
74 | this.dispatch('iSelect', 'append'); | 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 | const Select = findComponentUpward(this, 'iSelect'); | 84 | const Select = findComponentUpward(this, 'iSelect'); |
83 | if (Select) this.autoComplete = Select.autoComplete; | 85 | if (Select) this.autoComplete = Select.autoComplete; |
84 | }, | 86 | }, |
85 | beforeDestroy () { | 87 | beforeDestroy () { |
86 | this.dispatch('iSelect', 'remove'); | 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 | </script> | 93 | </script> |