@inertiajs/vue3 2.3.18 → 2.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -32,6 +32,8 @@ Vue page components should be placed in the `{{ $assist->inertia()->pagesDirecto
|
|
|
32
32
|
|
|
33
33
|
### Page Component Structure
|
|
34
34
|
|
|
35
|
+
Important: Vue components must have a single root element.
|
|
36
|
+
|
|
35
37
|
@verbatim
|
|
36
38
|
@boostsnippet("Basic Vue Page Component", "vue")
|
|
37
39
|
<script setup>
|
|
@@ -326,28 +328,46 @@ defineProps({
|
|
|
326
328
|
|
|
327
329
|
### Polling
|
|
328
330
|
|
|
329
|
-
|
|
331
|
+
Use the `usePoll` composable to automatically refresh data at intervals. It handles cleanup on unmount and throttles polling when the tab is inactive.
|
|
330
332
|
|
|
331
|
-
@
|
|
332
|
-
@boostsnippet("Polling Example", "vue")
|
|
333
|
+
@boostsnippet("Basic Polling", "vue")
|
|
333
334
|
<script setup>
|
|
334
|
-
import {
|
|
335
|
-
import { onMounted, onUnmounted } from 'vue'
|
|
335
|
+
import { usePoll } from '@inertiajs/vue3'
|
|
336
336
|
|
|
337
337
|
defineProps({
|
|
338
338
|
stats: Object
|
|
339
339
|
})
|
|
340
340
|
|
|
341
|
-
|
|
341
|
+
usePoll(5000)
|
|
342
|
+
</script>
|
|
342
343
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
344
|
+
<template>
|
|
345
|
+
<div>
|
|
346
|
+
<h1>Dashboard</h1>
|
|
347
|
+
<div>Active Users: {{ stats.activeUsers }}</div>
|
|
348
|
+
</div>
|
|
349
|
+
</template>
|
|
350
|
+
@endboostsnippet
|
|
351
|
+
|
|
352
|
+
@boostsnippet("Polling With Request Options and Manual Control", "vue")
|
|
353
|
+
<script setup>
|
|
354
|
+
import { usePoll } from '@inertiajs/vue3'
|
|
355
|
+
|
|
356
|
+
defineProps({
|
|
357
|
+
stats: Object
|
|
347
358
|
})
|
|
348
359
|
|
|
349
|
-
|
|
350
|
-
|
|
360
|
+
const { start, stop } = usePoll(5000, {
|
|
361
|
+
only: ['stats'],
|
|
362
|
+
onStart() {
|
|
363
|
+
console.log('Polling request started')
|
|
364
|
+
},
|
|
365
|
+
onFinish() {
|
|
366
|
+
console.log('Polling request finished')
|
|
367
|
+
},
|
|
368
|
+
}, {
|
|
369
|
+
autoStart: false,
|
|
370
|
+
keepAlive: true,
|
|
351
371
|
})
|
|
352
372
|
</script>
|
|
353
373
|
|
|
@@ -355,10 +375,14 @@ onUnmounted(() => {
|
|
|
355
375
|
<div>
|
|
356
376
|
<h1>Dashboard</h1>
|
|
357
377
|
<div>Active Users: {{ stats.activeUsers }}</div>
|
|
378
|
+
<button @click="start">Start Polling</button>
|
|
379
|
+
<button @click="stop">Stop Polling</button>
|
|
358
380
|
</div>
|
|
359
381
|
</template>
|
|
360
382
|
@endboostsnippet
|
|
361
|
-
|
|
383
|
+
|
|
384
|
+
- `autoStart` (default `true`) — set to `false` to start polling manually via the returned `start()` function
|
|
385
|
+
- `keepAlive` (default `false`) — set to `true` to prevent throttling when the browser tab is inactive
|
|
362
386
|
|
|
363
387
|
### WhenVisible
|
|
364
388
|
|
|
@@ -378,7 +402,6 @@ defineProps({
|
|
|
378
402
|
<div>
|
|
379
403
|
<h1>Dashboard</h1>
|
|
380
404
|
|
|
381
|
-
<!-- stats prop is loaded only when this section scrolls into view -->
|
|
382
405
|
<WhenVisible data="stats" :buffer="200">
|
|
383
406
|
<template #fallback>
|
|
384
407
|
<div class="animate-pulse">Loading stats...</div>
|
|
@@ -397,6 +420,32 @@ defineProps({
|
|
|
397
420
|
@endboostsnippet
|
|
398
421
|
@endverbatim
|
|
399
422
|
|
|
423
|
+
### InfiniteScroll
|
|
424
|
+
|
|
425
|
+
Automatically load additional pages of paginated data as users scroll:
|
|
426
|
+
|
|
427
|
+
@verbatim
|
|
428
|
+
@boostsnippet("InfiniteScroll Example", "vue")
|
|
429
|
+
<script setup>
|
|
430
|
+
import { InfiniteScroll } from '@inertiajs/vue3'
|
|
431
|
+
|
|
432
|
+
defineProps({
|
|
433
|
+
users: Object
|
|
434
|
+
})
|
|
435
|
+
</script>
|
|
436
|
+
|
|
437
|
+
<template>
|
|
438
|
+
<InfiniteScroll data="users">
|
|
439
|
+
<div v-for="user in users.data" :key="user.id">
|
|
440
|
+
{{ user.name }}
|
|
441
|
+
</div>
|
|
442
|
+
</InfiniteScroll>
|
|
443
|
+
</template>
|
|
444
|
+
@endboostsnippet
|
|
445
|
+
@endverbatim
|
|
446
|
+
|
|
447
|
+
The server must use `Inertia::scroll()` to configure the paginated data. Use the `search-docs` tool with a query of `infinite scroll` for detailed guidance on buffers, manual loading, reverse mode, and custom trigger elements.
|
|
448
|
+
|
|
400
449
|
## Server-Side Patterns
|
|
401
450
|
|
|
402
451
|
Server-side patterns (Inertia::render, props, middleware) are covered in inertia-laravel guidelines.
|