我能想到的最简单的方法是绑定md-active
到路由的路径参数。
<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>
零件:
export default {
methods: {
function isPath (path) {
return this.$route.path === path
}
}
}
您可能需要调整一些路径以匹配路由的参数,但这应该会为您提供正确路径上的活动选项卡