Api
useScriptEventPage()
Last updated by Harlan Wilton in chore: lint.
Access the current page title and path and trigger an event when they change.
Signature
function useScriptEventPage(callback?: (title: string, path: string) => void): Ref<{ title: string, path: string }> {}
Arguments
callback(optional) - A function that Nuxt calls when the page title or path changes.
Returns
A ref containing the current page title and path.
Examples
- Load a script when an element is visible.
<script setup lang="ts">
useScriptEventPage((ctx) => {
console.log(ctx.title, ctx.path)
})
</script>