0

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.

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

This was extremely helpful and finally got it working thanks!
Looks like this tip is also true for header/footer that contain remote fetched translated content, even if it is then the same content for every page in the same locale.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.