Answer the question
In order to leave comments, you need to log in
How to make night mode in Nuxt?
The task is to make night mode in Nuxt without using libraries.
At first I decided to do it on props , but when it came to the component <Nuxt />
I didn’t understand how to throw these props into it, namely boolean - data: () => ({ isNightMode: false })
Then I decided to make the state in Vuex in the store the same boolean isNightMode: false. And access to it by this.$store.state.vehicles.isNightMode. But I can’t figure out how to make all components react to a change in this boolean in the store.
How to do it better?
Answer the question
In order to leave comments, you need to log in
hmm, well, if through the store it can be like this:
<body>
<div id="app"
:class={
'light': this.$store.state.vehicles.isNightMode
'night': !this.$store.state.vehicles.isNightMode
}
>
</body>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question