Api

useScriptEventPage

API documentation for the useScriptEventPage function.

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 will be called 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>