From 6d017f5a6d102b49b4370b2214e8d19b36a5f56a Mon Sep 17 00:00:00 2001 From: yangdan8 <13532023084@139.com> Date: Tue, 23 Jan 2018 13:59:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3select-item=E5=BC=95=E8=B5=B7?= =?UTF-8?q?=E7=9A=84=E5=A4=A7=E9=87=8F=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决select-item引起的大量内存泄漏的bug --- src/components/select/option.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/select/option.vue b/src/components/select/option.vue index 0863097c..0733bb80 100644 --- a/src/components/select/option.vue +++ b/src/components/select/option.vue @@ -67,23 +67,27 @@ // 在使用函数防抖后,设置 key 后,不更新组件了,导致SearchLabel 不更新 #1865 updateSearchLabel () { this.searchLabel = this.$el.textContent; + }, + onSelectClose(){ + this.isFocus = false; + }, + onQueryChange(val){ + this.queryChange(val); } }, mounted () { this.updateSearchLabel(); this.dispatch('iSelect', 'append'); - this.$on('on-select-close', () => { - this.isFocus = false; - }); - this.$on('on-query-change', (val) => { - this.queryChange(val); - }); + this.$on('on-select-close', this.onSelectClose); + this.$on('on-query-change',this.onQueryChange); const Select = findComponentUpward(this, 'iSelect'); if (Select) this.autoComplete = Select.autoComplete; }, beforeDestroy () { this.dispatch('iSelect', 'remove'); + this.$off('on-select-close', this.onSelectClose); + this.$off('on-query-change',this.onQueryChange); } };