vue-router(二)后代路由


<div>
<ul class="tabBar">
<li v-for="(item,index) in tabList" :key="index"> <router-link :to="{path:item.url}">{{item.tit}}</router-link> </li>
</ul>
<router-view class="cont"></router-view>
</div>
.tabBar {
width: 100%;
height: 90px;
display: flex;
border-bottom: 1px solid #ccc;
}
.tabBar li {
display: flex;
flex:;
height: 90px;
}
.tabBar li a {
width: 100%;
line-height: 90px;
display: block;
text-align: center;
}
.router-link-active {
color: red; /*background-color: #003399;*/
border-bottom: 1px solid red;
}
.cont {
display: flex;
justify-content: center;
align-items: center; }
export default {
data() {
return {
isShow: true,
tabList: [
{ url: '/a', tit: "One" },
{ url: '/b', tit: "Two" },
{ url: '/c', tit: "Three" }
]
}
}
}
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router);
Router.prototype.animate = 0;
const _import = file => () => import('@/views/' + file + '.vue');
const _import_ = file => () => import('@/components/' + file + '.vue');
/*
* slide:页面切换动画
* login:是否需要登陆
* */
Vue.use(Router); export default new Router({
linkActiveClass: "router-link-active",//后代路由被激活时,给路由标签添加指定样式
routes: [
{
path: '/',
name: '首页',
component: _import('home/index'),
children: [
{
path: '',
redirect: '/a'
},//访问首页的时候默认访问后代路由中的a
{
path: '/a',
component: _import_('common/a')
},
{
path: '/b',
component: _import_('common/b')
},
{
path: '/c',
component: _import_('common/c')
}]
},
{
path: "/list",
name: "list",
component: _import("home/list"),
meta: {
slide: 1,
login: true
}
},
{
path: "/search",
name: "search",
component: _import("search/index"),
meta: {
slide: 1
}
},
{
path: "/center",
name: "center",
component: _import("center/index"),
meta: {
slide: 1
}
},]
})
vue-router(二)后代路由的更多相关文章
- vue.js利用vue.router创建前端路由
node.js方式: 利用node.js安装vue-router模块 cnpm install vue-router 安装完成后我们引入这个模板! 下载vue-router利用script引入方式: ...
- Vue Router路由守卫妙用:异步获取数据成功后再进行路由跳转并传递数据,失败则不进行跳转
问题引入 试想这样一个业务场景: 在用户输入数据,点击提交按钮后,这时发起了ajax请求,如果请求成功, 则跳转到详情页面并展示详情数据,失败则不跳转到详情页面,只是在当前页面给出错误消息. 难点所在 ...
- [Vue 牛刀小试]:第十四章 - 编程式导航与实现组件与 Vue Router 之间的解耦
一.前言 在上一章的学习中,通过举例说明,我们了解了 Vue Router 中命名路由.命名视图的使用方法,以及如何通过 query 查询参数传参,或者是采用 param 传参的方式实现路由间的参数传 ...
- Vue躬行记(8)——Vue Router
虽然Vue.js未提供路由功能,但是官方推出了Vue Router(即vue-router库),以插件的形式支持.它与Vue.js深度集成,可快速的创建单页应用(Single Page Applica ...
- [Vue 牛刀小试]:第十二章 - 使用 Vue Router 实现 Vue 中的前端路由控制
一.前言 前端路由是什么?如果你之前从事的是后端的工作,或者虽然有接触前端,但是并没有使用到单页面应用的话,这个概念对你来说还是会很陌生的.那么,为什么会在单页面应用中存在这么一个概念,以及,前端路由 ...
- 前端MVC Vue2学习总结(八)——Vue Router路由、Vuex状态管理、Element-UI
一.Vue Router路由 二.Vuex状态管理 三.Element-UI Element-UI是饿了么前端团队推出的一款基于Vue.js 2.0 的桌面端UI框架,手机端有对应框架是 Mint U ...
- [Vue 牛刀小试]:第十三章 - Vue Router 基础使用再探(命名路由、命名视图、路由传参)
一.前言 在上一章的学习中,我们简单介绍了前端路由的概念,以及如何在 Vue 中通过使用 Vue Router 来实现我们的前端路由.但是在实际使用中,我们经常会遇到路由传参.或者一个页面是由多个组件 ...
- 「vue基础」一篇浅显易懂的 Vue 路由使用指南( Vue Router 下)
大家好,在上一篇系列文章里,我们一起学习了路由的基本配置,如何创建路由和传参,本篇文章我们一起学习下 Navigation 导航和路由守卫的相关内容. Navigation 如果要改变当前路径,我们可 ...
- Vue Router 路由守卫:完整的导航解析流程
完整的导航解析流程 1 导航被触发. 2 在失活的组件里调用离开守卫. 3 调用全局的 beforeEach 守卫. 4 在重用的组件里调用 beforeRouteUpdate 守卫 (2.2+). ...
随机推荐
- JAVA国际化输出日期格式
1.建议控制台程序 使用 IntelliJ IDEA 创建 MAVEN项目, 不选别的选项,则为控制台程序. (其它方式创建的控制台程序可能编译不过) 2.源码如下: import java.tim ...
- 关于C#中的垃圾回收
http://cnn237111.blog.51cto.com/2359144/1343004 GC.Collect如何影响垃圾回收 主要是 //GC.Collect(); //GC.WaitF ...
- Spring MVC web.xml+servlet.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" " ...
- geoserver源码学习与扩展——增加服务接口
参看:http://www.cnblogs.com/sillyemperor/archive/2011/01/11/1929420.html 上文写的很详细了.
- C# 导出导入TXT文件
导出TXT关键类: using System; using System.Collections.Generic; using System.Linq; using System.Text; usin ...
- R 中的哪些命令或者包让你相见恨晚?--转载知乎
https://www.zhihu.com/question/24501195 节选: 看了这么多答案,觉得 Hadley Wickhamhad.co.nz 在R使用者的地位好高啊.其实我也觉得Had ...
- 设计模式--享元模式C++实现
1定义 使用共享对象可有效的支持大量细粒度的对象 2类图 角色分析 Flyweight抽象享元角色,一个产品的抽象,定义内部状态和外部状态的接口或者实现 ConcreteFlyweight具体享元角色 ...
- Tracing on Linux
The Linux tracing APIs are a relatively new addition to the kernel and one of the most powerful new ...
- linux-Centos7安装nginx
首先配置linux环境,我这里是刚刚装好linux,所以一次性安装了一系列我需要到的环境: yum install pcre pcre-devel zlib zlib-devel openssl op ...
- IOS-源代码管理工具(Git)
一.简介 什么是git? git是一款开源的分布式版本控制工具 在世界上所有的分布式版本控制工具中,git是最快.最简单.最流行的 git的起源 作者是Linux之父:Linus Benedict ...