zoukankan      html  css  js  c++  java
  • 测试平台系列(2)前端首页搭建

    前端首页搭建

    区域划分

    整个页面划分三个模块,头部信息区,导航栏,操作展示区
    image

    代码实现后效果
    image

    前端代码实现
    <template>
      <div>
        <div class="head"></div>
        <div class="navigation"></div>
        <div class="preview"></div>
      </div>
    </template>
    
    <script>
    export default {};
    </script>
    
    <style scoped>
    .head {
      position: absolute;
      top: 0px;
      left: 0px;
      right: 0px;
      height: 40px;
      background-color: antiquewhite;
    }
    .navigation {
      position: absolute;
      left: 0px;
      top: 40px;
       200px;
      bottom: 0px;
      background-color: aqua;
      overflow-y: scroll;
    }
    .preview {
      position: absolute;
      top: 40px;
      left: 200px;
      right: 0px;
      bottom: 0px;
      background-color: aquamarine;
      overflow-y: scroll;
      overflow-x: scroll;
    }
    </style>
    

    优化

    在一个页面中,如果把头部信息和导航栏还有操作区域的代码写在一个文件中,显得过于臃肿不好维护。
    前端的三个区域可写成组件的形式,划分到三个文件中来实现。

    在components下创建三个vue文件,分别存放三个部分的内容

    image

    在home文件中引用进来就可以啦
    image

    完整代码
    <template>
      <div>
        <app-head></app-head>
        <app-navigation></app-navigation>
        <app-preview></app-preview>
      </div>
    </template>
    
    <script>
    import AppHead from "@/components/header.vue"
    import AppNavigation from "@/components/navigation.vue"
    import AppPreview from "@/components/preview.vue"
    export default {
      components:{
        AppHead,AppNavigation,AppPreview
      }
    };
    </script>
    
    <style scoped>
    .head {
      position: absolute;
      top: 0px;
      left: 0px;
      right: 0px;
      height: 40px;
      background-color: antiquewhite;
    }
    .navigation {
      position: absolute;
      left: 0px;
      top: 40px;
       200px;
      bottom: 0px;
      background-color: aqua;
      overflow-y: scroll;
    }
    .preview {
      position: absolute;
      top: 40px;
      left: 200px;
      right: 0px;
      bottom: 0px;
      background-color: aquamarine;
      overflow-y: scroll;
      overflow-x: scroll;
    }
    </style>
    

    知识点掌握:

    Html

    在首页中使用到的标签只有 **div **

    Css

    样式操作这里用的比较多,也很简单,可自行百度查看
    自己不熟悉的有 position、 overflow-y

    Vue

    关键字scoped (这是Vue中样式私有化的实现方式,本文件样式只能本文件使用)
    组件 components
    注意:如果引用名称使用驼峰命名规则存在大写时,在页面使用时大写必须转小写,然后用“-”隔开才可。eg:<app-head></app-head>
    这里仅仅只是引用了页面,后续还有数据传递,父传子,子传父等。

  • 相关阅读:
    C++学习9 this指针详解
    福建省第八届 Triangles
    UVA 11584 Partitioning by Palindromes
    POJ 2752 Seek the Name, Seek the Fame
    UVA 11437 Triangle Fun
    UVA 11488 Hyper Prefix Sets (字典树)
    HDU 2988 Dark roads(kruskal模板题)
    HDU 1385 Minimum Transport Cost
    HDU 2112 HDU Today
    HDU 1548 A strange lift(最短路&&bfs)
  • 原文地址:https://www.cnblogs.com/TestingShare/p/15642022.html
Copyright © 2011-2022 走看看