Home.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div class="home">
  3. {{ $route.query.id }}
  4. <div class="nav">
  5. <router-link active-class="ha" to="/home/part1" class="hobby">画画</router-link>
  6. <router-link active-class="ha" to="/home/part2" class="hobby">舞蹈</router-link>
  7. </div>
  8. <div class="main">
  9. <!-- keep-alive 组件缓存
  10. include 控制保留那个组件内容的属性
  11. -->
  12. <!-- <keep-alive include="Part1">
  13. <router-view></router-view>
  14. </keep-alive> -->
  15. <!-- 多个存储 -->
  16. <keep-alive :include="['Part1']">
  17. <router-view></router-view>
  18. </keep-alive>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. created() {
  25. // 接收query传参
  26. //$route 路由参数
  27. console.log(this.$route.query)
  28. },
  29. }
  30. </script>
  31. <style scoped>
  32. .home {
  33. display: flex;
  34. justify-content: space-between;
  35. }
  36. .nav {
  37. width: 120px;
  38. height: 400px;
  39. display: flex;
  40. margin-top: 20px;
  41. flex-direction: column;
  42. /* margin: 30px 0 0 30px; */
  43. }
  44. .hobby {
  45. flex: 1;
  46. text-align: center;
  47. line-height: 200px;
  48. text-decoration: none;
  49. color: #000;
  50. border: 1px solid #ff0;
  51. }
  52. .main {
  53. flex: 2;
  54. /* width: 500px; */
  55. height: 500px;
  56. margin-top: 20px;
  57. margin-left: 30px;
  58. border: 1px solid purple;
  59. }
  60. .ha {
  61. color: red;
  62. }
  63. </style>