修复搜索栏显示BUG

This commit is contained in:
aixianling
2023-10-30 11:11:20 +08:00
parent 8b0650641e
commit eaadc9ae9c

View File

@@ -20,15 +20,14 @@ export default {
size: {default: "small"} size: {default: "small"}
}, },
computed: { computed: {
isSingleRow() { isSingleRow: v => v.height <= 45
return this.height <= 45
},
}, },
data() { data() {
return { return {
height: 0, height: 0,
rightHeight: 0, rightHeight: 0,
searchBarStyle: {} searchBarStyle: {},
observer: null
} }
}, },
methods: { methods: {
@@ -39,13 +38,21 @@ export default {
} else { } else {
this.searchBarStyle.marginBottom = '0' this.searchBarStyle.marginBottom = '0'
} }
},
initSize() {
this.height = this.$refs?.AiSearchBarZone?.offsetHeight
this.rightHeight = this.$refs?.searchRightZone?.offsetHeight
} }
}, },
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
this.height = this.$refs?.AiSearchBarZone?.offsetHeight this.initSize()
this.rightHeight = this.$refs?.searchRightZone?.offsetHeight this.observer = new ResizeObserver(this.initSize)
this.observer.observe(this.$refs?.AiSearchBarZone)
}) })
},
beforeDestroy() {
this.observer?.disconnect()
} }
} }
</script> </script>
@@ -62,7 +69,7 @@ export default {
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
} }
:deep(.searchLeftZone ){ :deep(.searchLeftZone ) {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
display: flex; display: flex;
@@ -71,7 +78,7 @@ export default {
gap: 8px; gap: 8px;
} }
:deep(.searchRightZone ){ :deep(.searchRightZone ) {
display: flex; display: flex;
align-items: center; align-items: center;
flex-shrink: 0; flex-shrink: 0;
@@ -95,7 +102,7 @@ export default {
margin-top: 8px; margin-top: 8px;
} }
:deep( .searchLeftZone > .el-button), :deep( .searchRightZone > .el-button ){ :deep( .searchLeftZone > .el-button), :deep( .searchRightZone > .el-button ) {
margin-left: 0; margin-left: 0;
} }
</style> </style>