Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Currently, I am having 3 layouts:

  1. has header and sidebar
  2. has header no sidebar
  3. has no header nor sidebar

What is the way to extend the layout with options whether to turn on or off the sidebar and header? These are 3 possibilities but I'm sure there should be better way

  1. Use 1 layout with vuex state. Set the showHeader and showSidebar beforeMount
  2. Use 1 layout with $route condition to show header and sidebar
  3. Use 3 layouts

Does anyone know any better way?

question from:https://stackoverflow.com/questions/65882458/how-to-better-extend-layout-with-conditional-component-in-nuxt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

If displaying header statically, i would prefer to separate 2 layout.

  1. has header
  2. has no header

And control the sidebar open/close state from vuex by user prefer.

If header preference is dynamically,

one default layout and control header and sidebar open/close state from vuex


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...