fix(option): selectemitter was not turned off when it was destroyed (#2450)

This commit is contained in:
C.Y.Kun 2021-07-13 09:25:37 +08:00 committed by GitHub
parent 6305f7af80
commit f6b17cb79a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import {
computed,
getCurrentInstance,
watch,
onBeforeUnmount,
} from 'vue'
import { getValueByPath, escapeRegexpString } from '@element-plus/utils/util'
import {
@ -108,6 +109,10 @@ export function useOption(props, states) {
// Emitter
select.selectEmitter.on(selectEvents.queryChange, queryChange)
onBeforeUnmount(() => {
select.selectEmitter.off(selectEvents.queryChange, queryChange)
})
return {
select,
currentLabel,