I am using Vue Material Tabs https://vuematerial.github.io/#/components/tabs and I would like to know if there is a way to implement Vue Router with tabs.
Using named Views I can show a different router view in every tab but I want to know how to get a different route in every active tab.
Example:
Click the Tab 1 has the route "/"
Click the Tab 2 has the route "/user"
And in the browser if I go to the "/user" route I want it to show the Tab #2 activated with their route view and If I write the main route "/" I want it to show the Tab 1# with their content.
The easiest way I can think would be to bind md-active
to the route's path parameter.
<md-tab id="movies" md-label="Movies" :md-active="isPath('/movies')">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deserunt dolorum quas amet cum vitae, omnis! Illum quas voluptatem, expedita iste, dicta ipsum ea veniam dolore in, quod saepe reiciendis nihil.</p>
</md-tab>
<md-tab id="books" md-label="Books" :md-active="isPath('/books')">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deserunt dolorum quas amet cum vitae, omnis! Illum quas voluptatem, expedita iste, dicta ipsum ea veniam dolore in, quod saepe reiciendis nihil.</p>
</md-tab>
component:
export default {
methods: {
function isPath (path) {
return this.$route.path === path
}
}
}
you might have to tweak some of the paths to match the route's parameter but this should give you the active tab on the correct path