Skip to content

Commit 7b3570d

Browse files
committed
fix: types for ref triggers
1 parent 9ef9a45 commit 7b3570d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

docs/content/docs/1.guides/1.script-triggers.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Nuxt Scripts provides several ways to trigger the loading of scripts.
66

77
::code-group
88

9-
```ts [useScript]
9+
```ts [useScript - Ref]
1010
import { useTimeout } from '@vueuse/core'
1111

1212
const { ready } = useTimeout(3000)
@@ -18,6 +18,16 @@ useScript({
1818
})
1919
```
2020

21+
```ts [useScript - Computed]
22+
const route = useRoute()
23+
useScript({
24+
src: 'https://example.com/script.js',
25+
}, {
26+
// only if route has a specific query
27+
trigger: computed(() => !!route.query.affiliateId),
28+
})
29+
```
30+
2131
```ts [Registry Script]
2232
import { useTimeout } from '@vueuse/core'
2333

src/runtime/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { UseScriptOptions, DataKeys, SchemaAugmentations, ScriptBase } from '@unhead/schema'
2-
import type { UseScriptInput, VueScriptInstance } from '@unhead/vue'
1+
import type { DataKeys, SchemaAugmentations, ScriptBase } from '@unhead/schema'
2+
import type { UseScriptInput, VueScriptInstance, UseScriptOptions } from '@unhead/vue'
33
import type { ComputedRef, Ref } from 'vue'
44
import type { InferInput, ObjectSchema } from 'valibot'
55
import type { Import } from 'unimport'

0 commit comments

Comments
 (0)