$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:
truewhen 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 Tue, Apr 5, 2022
Nazaré da Piedade
Mosaab Emam
Sylvain Marroufin
Iljs Путлер Капут
Daniel Roe
Heitor Ramon Ribeiro
Nero
Sébastien Chopin
Clément Ollivier
Yoon Han
Ikko Ashimine
FamCodings
Ayouli
F. Hinkelmann
felipesuri
Christophe Carvalho Vilas-Boas
Leoš Literák
Trizotti
Marcello Bachechi
Rodolphe
Thomas Underwood
Shek Evgeniy
Lukasz Formela
Hugo Torzuoli
Kareem Dabbeet
tramplay
verebelyicsaba
Adam
Nate Butler
Sandra Rodgers
Arpit Patidar
Matthew Kuehn
Steven DUBOIS
Travis Lindsey
syagawa
Maxime
かる
Al Power
Florent Delerue
quanghm
José Manuel Casani Guerra
Unai Mengual
kazuya kawaguchi
Michael Lynch
Tomachi
pooya parsa
Meir Roth