fix: 取消固定
This commit is contained in:
parent
581b8533f4
commit
2c6c56a45b
@ -121,30 +121,8 @@ const handleSelect = (payload) => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetRef = ref(null)
|
|
||||||
const isFixed = ref(false)
|
|
||||||
|
|
||||||
const handleScroll = () => {
|
|
||||||
if (!targetRef.value) return
|
|
||||||
|
|
||||||
const rect = targetRef.value.$el
|
|
||||||
? targetRef.value.$el.getBoundingClientRect()
|
|
||||||
: targetRef.value.getBoundingClientRect()
|
|
||||||
|
|
||||||
isFixed.value = rect.top <= -140
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await handleQuery()
|
await handleQuery()
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(targetRef, (el) => {
|
|
||||||
if (!el) return
|
|
||||||
window.addEventListener('scroll', handleScroll)
|
|
||||||
})
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
window.removeEventListener('scroll', handleScroll)
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user