修复 多个 下拉组件,切换 隐藏问题
This commit is contained in:
parent
2b23b4df51
commit
76c5387753
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="" style="position: relative;">
|
||||
<view @click.stop="handleSelectSwitch">
|
||||
<view @click.stop="handleRootClick" class="" style="position: relative;">
|
||||
<view @click="handleSelectSwitch">
|
||||
<slot v-if="$slots.default"></slot>
|
||||
<default-select-input v-else :placeholder="placeholder" :show="show" :list="filDataList" :value="value" :isWhite="isWhite" :customStyle="customStyle"></default-select-input>
|
||||
</view>
|
||||
@ -40,6 +40,8 @@
|
||||
drop: 'drop'
|
||||
}
|
||||
|
||||
const selectDropEventName = "selectDropEventName"
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
filDataList() {
|
||||
@ -133,22 +135,31 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
componentId: uni.$u.guid(20),
|
||||
show: false,
|
||||
modeEnum: Object.assign({}, modeEnum)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
uni.$on(pageEventNames.globalClick, this.handleDocumentClick);
|
||||
uni.$on(selectDropEventName, this.listenSelectDrop);
|
||||
},
|
||||
|
||||
unmounted() {
|
||||
uni.$off(pageEventNames.globalClick, this.handleDocumentClick);
|
||||
uni.$off(selectDropEventName, this.listenSelectDrop);
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleDocumentClick(){
|
||||
this.show = false
|
||||
},
|
||||
listenSelectDrop(e) {
|
||||
// 忽略当前组件发出的事件消息
|
||||
if(e != this.componentId) {
|
||||
this.show = false
|
||||
}
|
||||
},
|
||||
handleSelectSwitch() {
|
||||
// this.$emit('update:show', !this.show)
|
||||
this.show = !this.show
|
||||
@ -162,6 +173,9 @@
|
||||
},
|
||||
onListChange(val){
|
||||
this.$emit('update:resObject', val)
|
||||
},
|
||||
handleRootClick() {
|
||||
uni.$emit(selectDropEventName, this.componentId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user