修复搜索栏显示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"}
},
computed: {
isSingleRow() {
return this.height <= 45
},
isSingleRow: v => v.height <= 45
},
data() {
return {
height: 0,
rightHeight: 0,
searchBarStyle: {}
searchBarStyle: {},
observer: null
}
},
methods: {
@@ -39,13 +38,21 @@ export default {
} else {
this.searchBarStyle.marginBottom = '0'
}
},
initSize() {
this.height = this.$refs?.AiSearchBarZone?.offsetHeight
this.rightHeight = this.$refs?.searchRightZone?.offsetHeight
}
},
mounted() {
this.$nextTick(() => {
this.height = this.$refs?.AiSearchBarZone?.offsetHeight
this.rightHeight = this.$refs?.searchRightZone?.offsetHeight
this.initSize()
this.observer = new ResizeObserver(this.initSize)
this.observer.observe(this.$refs?.AiSearchBarZone)
})
},
beforeDestroy() {
this.observer?.disconnect()
}
}
</script>