HomeView.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div class="home">
  3. <a-layout id="components-layout-demo-top-side-2">
  4. <a-layout-header class="header">
  5. <HomeHeader :collapse.sync="collapse" :is-login="true" />
  6. </a-layout-header>
  7. <a-layout class="main_body">
  8. <a-layout-sider
  9. v-model="collapse"
  10. :trigger="null"
  11. width="200"
  12. style="background: #fff"
  13. :collapsible="true"
  14. :collapsed-width="60"
  15. >
  16. <HomeAside :collapse="collapse" />
  17. </a-layout-sider>
  18. <!-- 内容 -->
  19. <a-layout-content class="home-page">
  20. <router-view />
  21. </a-layout-content>
  22. </a-layout>
  23. </a-layout>
  24. </div>
  25. </template>
  26. <script>
  27. import "@/style/common.css";
  28. export default {
  29. name: "HomeView",
  30. components: {
  31. HomeHeader: () => import("@/components/home/HomeHeader.vue"),
  32. HomeAside: () => import("@/components/home/HomeAside.vue"),
  33. },
  34. data() {
  35. return {
  36. collapse: true, // 侧边栏是否收起
  37. asideWidth: "16%",
  38. contentWidth: "84%",
  39. contentHeight: 450,
  40. };
  41. },
  42. watch: {
  43. fold(val) {
  44. let app = this;
  45. setTimeout(() => {
  46. app.suitHeight();
  47. }, 100);
  48. },
  49. },
  50. mounted() {
  51. this.suitHeight();
  52. },
  53. methods: {
  54. suitHeight() {
  55. let app = this;
  56. this.$nextTick(() => {
  57. const height = document.getElementsByClassName("home")[0].clientHeight;
  58. app.contentHeight = height - 60 - 24;
  59. app.$forceUpdate();
  60. });
  61. },
  62. },
  63. };
  64. </script>
  65. <style lang="less" scoped>
  66. .home {
  67. width: 100%;
  68. height: 100%;
  69. .header {
  70. height: 60px;
  71. padding: 0;
  72. line-height: 60px;
  73. }
  74. .main_body{
  75. height:calc(100vh - 60px);
  76. }
  77. .home-page {
  78. display: inline-block;
  79. background: #fff;
  80. margin: 0;
  81. transition: all 1s;
  82. overflow: hidden;
  83. }
  84. }
  85. </style>