Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell what layout is being used within a Nuxt.js component?

I have two Nuxt.js layouts, default.vue and secondary.vue. There's the same footer.vue component that is being used in both of these layouts. I'd like to change some CSS classes inside of the footer.vue component based upon which layout the component is being used in. How Does one know what layout is being used from within a component nested in Nuxt.js layout?

like image 775
user782860 Avatar asked Oct 18 '25 22:10

user782860


1 Answers

You can use the following:

this.$nuxt.$data.layoutName

Which will return the name of the layout file used.

like image 108
Ohgodwhy Avatar answered Oct 20 '25 13:10

Ohgodwhy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!