2022-12-18 07:15:41 +09:00
|
|
|
<script setup lang="ts">
|
2024-03-05 23:48:58 +09:00
|
|
|
const { as = 'div', active } = defineProps<{
|
|
|
|
as: any
|
|
|
|
active: boolean
|
|
|
|
}>()
|
|
|
|
|
2022-12-18 07:15:41 +09: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>
|