Static GitHub Issues

[2017] Cannot switch custom layouts dynamically

prev: Route change from link stored in DB?
next: Unable to generate static HTML files in SPA mode.

I want to switch the layout by a button, when I press the button, I'm going to put the state in localStorage,e.g localStorage.setItem('themeFlag',true). then, I'll get the state in about.vue, but localStorage is not defined,e.g export default{ layout: (function(){ let themeFlag = localStorage.getItem('themeFlag') return themeFlag ? 'vertical':'horizontal' }()) } Then I tried another method, e.g let themeFlag = '' export default{ mouted(){ themeFlag = localStorage.getItem('themeFlag') }, layout:(function(){ return themeFlag ? 'vertical':'horizontal' }()) } but, in layout, themeFlag is an empty string. I've tried use vuex store, but in the layou, I still can't get the themeFlag.And finally, I found that layout rendered before beforeCreate. So, I'm going to set the layout dynamically? thanks.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1791">#c1791</a>)</em></sub></div>