Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
356 views
in Technique[技术] by (71.8m points)

vue.js - Vuetify: Changing navbar entirely at breakpoint

I'm using nuxt and vuetify, and I have a pretty normal default layout with a navbar added, as seen below:

<v-app dark>
 <v-app-bar height="60" max-height="60" app>
   <Navbar />
 </v-app-bar>
...
<v-app />

With Navbar being a custom component. However I need to swap out the current component (as in, totally change the grid-based layout to the point that adding a few breakpoints for justify and align content and whatnot would not suffice) for another one, containing most of the components of the first Navbar, just with a different layout.

What would be the most efficient method for swapping out the two different layouts/components at different screen sizes?

I was thinking of using vue-mq but I was wondering if there were better ways of doing this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Vuetify provides breakpoints by default which you can access through this.$vuetify.breakpoint inside your Vue components. Creating a computed prop that is pointing to the breakpoint props and conditionally rendering NavBar or another component depending on the computed prop could be the way.

More information about Vuetify Breakpoint Service Object


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...