Reputation: 2081
I have a header on every page thats generally static — besides the button that needs to update based on the page. Ideally I would like to have a variable called link
in static/content/xxx
and then to call it from layouts/default
. However it does not seem that I have access to any of the variables in my static content. Being new to vue and nuxt I was hoping for some guidance. I tried using asyncData
however, it doesn't seem to get called at all in my layout.
Upvotes: 0
Views: 778
Reputation: 750
a layout is a static wrapper that will wrap your main content. the main idea behind using layout is to not write the same content again and again. If you work with Vue only project than this type of functionality can be accessed by the using the child routes.
just add the common layout as the parent Component and the changed or different content as the child components.
back to the point, if you have different button content depending upon the pages than don't place it in the layout instead pass through the components individually.
whereas the static folder in the nuxt application holds the data that should not be changed such as the css files or external script files just take and example of bootstrap and jquery these are the libraries that are embeded in the application, instead of changing their internals we just use them. this type of content is placed in static directory (folder)
I hope it helps
Upvotes: 2