一、底部导航组件的编写

tab-bar.png

1-1 .router-link-active

让被点击的当前路由颜色改变

  1. #footer ul li.router-link-active{
  2. color:#E54847
  3. }
  1. <template>
  2. <footer id="footer">
  3. <ul>
  4. <router-link tag="li" to="/movie" >
  5. <i class="iconfont icondianying1"></i>
  6. <p>电影</p>
  7. </router-link>
  8. <router-link tag="li" to="/cinema">
  9. <i class="iconfont icondianyingyuan"></i>
  10. <p>影院</p>
  11. </router-link>
  12. <router-link tag="li" to="/mine">
  13. <i class="iconfont iconicon-test"></i>
  14. <p>个人中心</p>
  15. </router-link>
  16. </ul>
  17. </footer>
  18. </template>
  19. <script>
  20. export default {
  21. name:"TabBar"
  22. }
  23. </script>
  24. <style scoped>
  25. #footer{
  26. color:#666;
  27. border-top: 1px solid #999;
  28. position:fixed;
  29. left:0;
  30. bottom:0;
  31. height:100px;
  32. width:100vw;
  33. }
  34. .active{
  35. color:#E54847
  36. }
  37. #footer ul{
  38. height: 100%;
  39. display: flex;
  40. }
  41. #footer li{
  42. font-size: 30px;
  43. flex:1;
  44. display: flex;
  45. flex-direction: column;
  46. justify-content:space-evenly;
  47. align-items: center;
  48. }
  49. #footer i.iconfont{
  50. font-size: 36px !important;
  51. }
  52. #footer ul li.router-link-active{
  53. color:#E54847
  54. }
  55. </style>

二、父子组件的通信

tab.gif

  1. Components/Header/index.vue
  2. <template>
  3. <header id="header">
  4. <h1>{{title}}</h1>
  5. </header>
  6. </template>
  7. <script>
  8. export default {
  9. name:"Header",
  10. props:{
  11. title:{
  12. type:String,
  13. default:"豆瓣电影"
  14. }
  15. }
  16. }
  17. </script>
  1. //父组件通过属性给子组件传递参数
  2. views/Movie/index.vue
  3. <template>
  4. <div>
  5. <div>
  6. <Header title="豆瓣电影"></Header>
  7. <tab-bar></tab-bar>
  8. </div>
  9. </div>
  10. </template>