$nuxt: The Nuxt helper
$nuxt is a helper designed to improve user experience.
For more info on the Nuxt helper check out the context and helpers chapter in the Concepts book
Connection checker
-
isOffline
-
Type:
Boolean
-
Description:
true
when the user's internet connection becomes offline
-
Type:
-
isOnline
-
Type:
Boolean
-
Description: Opposite of
isOffline
-
Type:
layouts/default.vue
<template>
<div>
<div v-if="$nuxt.isOffline">You are offline</div>
<nuxt />
</div>
</template>
Refreshing page data
-
refresh()
- When you want to only refresh the data provided by asyncData or fetch
example.vue
<template>
<div>
<div>{{ content }}</div>
<button @click="refresh">Refresh</button>
</div>
</template>
<script>
export default {
asyncData() {
return { content: 'Created at: ' + new Date() }
},
methods: {
refresh() {
this.$nuxt.refresh()
}
}
}
</script>
Controlling the loading bar
-
$loading
- When you want to control Nuxt's loading bar programmatically
export default {
mounted() {
this.$nextTick(() => {
this.$nuxt.$loading.start()
setTimeout(() => this.$nuxt.$loading.finish(), 500)
})
}
}
Edit this page on GitHub
Updated at Mon, Aug 19, 2024
Sébastien Chopin
Nazaré da Piedade
Nobu
川音리오
Maciek Palmowski
Nestor Vera
Daniel Roe
Yue Yang
Jeronimas
Clément Ollivier
Alexander Lichter
N3-rd
Adrien Zaganelli
Mag
Stefan Huber
Olga Bulat
Paiva
Florian Reuschel
Savas Vedova
HIJACK
Vinícius Alves
Kareem Dabbeet
Valentín Costa
Ryan Skinner
Alex Hirzel
Ajeet Chaulagain
René Eschke
Nico Devs
Muhammad
Naoki Hamada
Tom
Yann Aufray
Anthony Chu
Nuzhat Minhaz
Lucas Portet
Richard Schloss
Bobby
bpy
Antony Konstantinidis
Hibariya
Jose Seabra
Eze
Florian Lefebvre
Lucas Recoaro
Julien SEIXAS