2022-12-17 22:15:41 +00:00
|
|
|
<script setup lang="ts">
|
2024-03-05 14:48:58 +00:00
|
|
|
const { as = 'div', active } = defineProps<{
|
|
|
|
as: any
|
|
|
|
active: boolean
|
|
|
|
}>()
|
|
|
|
|
2022-12-17 22:15:41 +00:00
|
|
|
const el = ref()
|
|
|
|
|
|
|
|
watch(() => active, (active) => {
|
|
|
|
const _el = unrefElement(el)
|
|
|
|
|
|
|
|
if (active && _el)
|
|
|
|
_el.scrollIntoView({ block: 'nearest', inline: 'start' })
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<component :is="as" ref="el">
|
|
|
|
<slot />
|
|
|
|
</component>
|
|
|
|
</template>
|