这篇文章主要给大家介绍了关于vue实现tab路由切换组件的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
前言
本文介绍的是使用vue自带的vue-router.js路由实现分页切换功能,下面话不多说了,来一起看看详细的实现代码吧
实现图片如下
下列为实现代码
css:
*{ margin: 0; padding: 0; } #app ul{ width: 300px; height: 30px; list-style: none; } #app>ul>li{ width: 100px; height: 30px; float: left; }
html:
<div id="app"> <ul> <li> 第一页</li><li> 第二页</li><li> 第三页</li></ul></div> <div> <ul> <li>News 01</li><li>News 02</li><li>News 03</li></ul></div> <div> <ul> <li>message 01</li><li>message 02</li><li>message 03</li></ul></div> <div> <h1>Home</h1>home1home2</div> <h1>我是home1</h1> <h1>我是home2</h1>
js.
let Dyy={template:`#DyyDay`}; let Dey={template:`#DeyDay`}; let Dsy={template:`#DsyDay`}; let home1={template:`#home1`}; let home2={templat<a>本文来源gao*daima.com搞@代#码&网6</a>e:`#home2`}; let router=new VueRouter({ routes:[ { path:'/',redirect:"dyy" }, { path:'/dyy',component:Dyy }, { path:'/dey',component:Dey }, { path:'/dsy',component:Dsy , children:[ {path:'/dsy/home1',component:home1}, {path:'/dsy/home2',component:home2} ] }] }); let app=new Vue({ router }).$mount('#app')
总结
到此这篇关于vue实现tab路由切换组件的文章就介绍到这了,更多相关vue tab路由切换组件内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
以上就是vue实现tab路由切换组件的方法实例的详细内容,更多请关注gaodaima搞代码网其它相关文章!