admin管理员组

文章数量:1405910

Today I started playing with NuxtJS and was wondering what the best way to set/retrieve global data would be?

For example a phone number that gets repeated throughout a site, should be managed from a single location.

Would AsyncData be the way to go? Is that overkill?

In Vue.js you'd have global data attached to the main Vue instance. What is the Nuxt equivalent of this (if there is one).

Today I started playing with NuxtJS and was wondering what the best way to set/retrieve global data would be?

For example a phone number that gets repeated throughout a site, should be managed from a single location.

Would AsyncData be the way to go? Is that overkill?

In Vue.js you'd have global data attached to the main Vue instance. What is the Nuxt equivalent of this (if there is one).

Share Improve this question asked Apr 30, 2018 at 13:23 crinklebatcrinklebat 3167 silver badges17 bronze badges 1
  • 1 Wouldn't state management like VueX a better approach in general for global data? Attaching data to the vue instance for the sake of data storage doesn't seem like a very flexible approach. Also vuex is directly supported by nuxt. – Philip Feldmann Commented Apr 30, 2018 at 13:36
Add a ment  | 

1 Answer 1

Reset to default 5

Take a look at Vuex, the vue state management pattern and library.

It serves as a centralized store for all the ponents in a vue application.

本文标签: javascriptNuxt JSWherehow to set global dataStack Overflow