注意vue-router嵌套路由的问题:子路由组件中的class样式被覆盖,当需要用到路由嵌套时,clas命名时注意不要相同。

点击查看上一篇vue-router嵌套路由具体

例子:

子路由a组件中:

<template>
<div class="children">我是a组件</div>
</template>
<style scoped>
.children{
font-size: 16px;
color: red;
text-align: center;
margin-top: 100px;
}
</style>

本页面standard组件:

<template>
<div class="standard">
<headerBack title="嵌套路由"></headerBack>
<div>
<div class="tab">
<router-link to="/standard/a">
<div class="children">我是a组件</div>
</router-link>
<router-link to="/standard/b">
<div class="children">我是b组件</div>
</router-link>
<router-link to="/standard/c">
<div class="children">我是c组件</div>
</router-link>
</div>
<router-view/>
</div>
</div>
</template> <script>
import headerBack from "./../../components/header"; export default {
components: { headerBack },
};
</script>
<style lang="less" scoped>
.standard {
.tab {
display: flex;
justify-items: center;
justify-content: space-around;
}
.children {
border-radius: 5px;
text-align: center;
font-size: 16px;
margin: 20px 0;
background-color: #1989fa;
padding: 10px;
color: #fff;
}
}
</style>

这样子a组件的children样式没生效:样式效果为standard组件中的children样式,结果如下:

原因是a组件的children样式被覆盖了:

当子路由a组件中改变class名时且命名不相同时:

<template>
<div class="a">我是a组件</div>
</template>
<style scoped>
.a{
font-size: 16px;
color: red;
text-align: center;
margin-top: 100px;
}
</style>

效果为:(正常)

当然也可以给样式权重优先级来解决。

最新文章

  1. EF6 CodeFirst+Repository+Ninject+MVC4+EasyUI实践(三)
  2. c#上iOS apns p12文件制作记录 iOS推送证书制件
  3. JAVA B/S系统实现客户端屏幕截图,Java版的QQ截图
  4. c语言例子递归与整数逆序
  5. 【ACM/ICPC2013】线段树题目集合(一)
  6. j
  7. 简易google地图api调用
  8. jquery mobile转场时加载js失效
  9. WIN7 Net Configuration Assistant打不开
  10. ural1494 Monobilliards
  11. hello spring春天来了
  12. 浏览器插件使用socks5代理
  13. 【DB2】SQL1585N 由于没有具有兼容页面大小的可用系统临时表空间,因此无法创建临时表。SQLSTATE=54048
  14. JS-排序详解-快速排序
  15. CSS图标文字不对齐
  16. PAT 1023 Have Fun with Numbers[大数乘法][一般]
  17. 迷你MVVM框架 avalonjs 学习教程17、avalon的一些配置项
  18. 收集Cocos2d提供的字体!共57种
  19. js 打印软件 Lodop
  20. 北京Uber优步司机奖励政策(1月15日)

热门文章

  1. SQL Injection(Blind)
  2. python 实例化 类方法 静态方法 成员变量 实例方法 等调用
  3. 【Python开发】查看数据类型
  4. 熟悉GitHub、VS工具的使用(《构建之法》第二次作业)
  5. Hanlp配置自定义词典遇到的问题与解决方法
  6. Hadoop三种架构介绍及搭建
  7. 2. zookeeper介绍及集群搭建
  8. SYN攻击源码
  9. 搭建集群版Eureka Server
  10. Java Web开发技术教程入门-JavaBean组件与Servlet