首页 > 其他分享 >路飞项目前端主页搭建

路飞项目前端主页搭建

时间:2022-11-02 13:45:31浏览次数:57  
标签:主页 url 路飞 components 组件 path margin color 搭建

前端主页

图片准备

首先把主页需要到图片资源放到项目的img文件夹下

image

页头组件:components/Header.vue

<template>
    <div class="header">
        <div class="slogan">
            <p>老男孩IT教育 | 帮助有志向的年轻人通过努力学习获得体面的工作和生活</p>
        </div>
        <div class="nav">
            <ul class="left-part">
                <li class="logo">
                    <router-link to="/">
                        <img src="../assets/img/head-logo.svg" alt="">
                    </router-link>
                </li>
                <li class="ele">
                    <span @click="goPage('/free-course')" :class="{active: url_path === '/free-course'}">免费课</span>
                </li>
                <li class="ele">
                    <span @click="goPage('/actual-course')" :class="{active: url_path === '/actual-course'}">实战课</span>
                </li>
                <li class="ele">
                    <span @click="goPage('/light-course')" :class="{active: url_path === '/light-course'}">轻课</span>
                </li>
            </ul>

            <div class="right-part">
                <div>
                    <span>登录</span>
                    <span class="line">|</span>
                    <span>注册</span>
                </div>
    		</div>
        </div>
    </div>

</template>

<script>

    export default {
        name: "Header",
        data() {
            return {
                url_path: sessionStorage.url_path || '/',
            }
        },
        methods: {
            goPage(url_path) {
                // 已经是当前路由就没有必要重新跳转
                if (this.url_path !== url_path) {
                    this.$router.push(url_path);
                }
                sessionStorage.url_path = url_path;
            },
        },
        created() {
            sessionStorage.url_path = this.$route.path;
            this.url_path = this.$route.path;
        }
    }
</script>

<style scoped>
    .header {
        background-color: white;
        box-shadow: 0 0 5px 0 #aaa;
    }

    .header:after {
        content: "";
        display: block;
        clear: both;
    }

    .slogan {
        background-color: #eee;
        height: 40px;
    }

    .slogan p {
        width: 1200px;
        margin: 0 auto;
        color: #aaa;
        font-size: 13px;
        line-height: 40px;
    }

    .nav {
        background-color: white;
        user-select: none;
        width: 1200px;
        margin: 0 auto;

    }

    .nav ul {
        padding: 15px 0;
        float: left;
    }

    .nav ul:after {
        clear: both;
        content: '';
        display: block;
    }

    .nav ul li {
        float: left;
    }

    .logo {
        margin-right: 20px;
    }

    .ele {
        margin: 0 20px;
    }

    .ele span {
        display: block;
        font: 15px/36px '微软雅黑';
        border-bottom: 2px solid transparent;
        cursor: pointer;
    }

    .ele span:hover {
        border-bottom-color: orange;
    }

    .ele span.active {
        color: orange;
        border-bottom-color: orange;
    }

    .right-part {
        float: right;
    }

    .right-part .line {
        margin: 0 10px;
    }

    .right-part span {
        line-height: 68px;
        cursor: pointer;
    }
</style>

页脚组件:components/Footer.vue

<template>
    <div class="footer">
        <ul>
            <li>关于我们</li>
            <li>联系我们</li>
            <li>商务合作</li>
            <li>帮助中心</li>
            <li>意见反馈</li>
            <li>新手指南</li>
        </ul>
        <p>Copyright © luffycity.com版权所有 | 京ICP备17072161号-1</p>
    </div>
</template>

<script>
    export default {
        name: "Footer"
    }
</script>

<style scoped>
    .footer {
        width: 100%;
        height: 128px;
        background: #25292e;
        color: #fff;
    }

    .footer ul {
        margin: 0 auto 16px;
        padding-top: 38px;
        width: 810px;
    }

    .footer ul li {
        float: left;
        width: 112px;
        margin: 0 10px;
        text-align: center;
        font-size: 14px;
    }

    .footer ul::after {
        content: "";
        display: block;
        clear: both;
    }

    .footer p {
        text-align: center;
        font-size: 12px;
    }
</style>

轮播图组件:components/Banner.vue

<template>
    <div id="banner">
        <el-carousel height="400px">
            <el-carousel-item v-for="item in 4" :key="item">
                <img src="../assets/img/banner1.png" alt="">
            </el-carousel-item>
        </el-carousel>
    </div>
</template>

<script>
    export default {
        name: "Banner"
    }
</script>

<style scoped>
    .el-carousel__item {
        height: 400px;
        min-width: 1200px;
    }
    .el-carousel__item img {
        height: 400px;
        margin-left: calc(50% - 1920px / 2);
    }
</style>

组件的使用

在views的.vue文件中执行以下步骤:

1.导入写好的组件:

import Header from '../components/Header' //Header是组件名,from后面是组件相对的位置
import Footer from '../components/Footer'
import Banner from '../components/Banner'

2.在components里添加组件名:

  components: {
    Header,
    Footer,
    Banner
  }

3.在template模块添加组件:书写方式如图

image

标签:主页,url,路飞,components,组件,path,margin,color,搭建
From: https://www.cnblogs.com/suncolor/p/16850522.html

相关文章

  • GWT环境搭建
    简介GoogleWebToolkit(简称GWT)的出现为我们提供了这种可能。GWT是Google推出的Ajax应用开发包,支持开发者使用Java语言开发Ajax应用。GWT框架本身是开源......
  • 详解Three.js环境搭建与一个简单例子
    一、环境准备1.开发工具选用WebStorm,因为WebStorm自带了一个本地服务器,而Three.js的很多特性需要在服务器端才能展现。2.three.js库的下载与导入3.打开调用three.js的html的......
  • 修改XMAPP中Apache的默认访问的主页
    默认主页修改:0.本人XAMPP版本为3.21.修改httpd-conf:即下图DocumentRoot后的路径以及下一行的路径,即为默认路径,因此将这两个路径修改为自己项目的路径即可2.本人修改后3.......
  • springCloud分布式框架搭建教程
    集群:指一个项目部署在不同的服务器,通过负载均衡来访问,形成集群。分布式:指项目中不同的模块可以独立运行。 Springboot是什么?是推出解决传统框架配置文件繁杂冗余,基于maven......
  • springboot + mybatis 框架的搭建
    分享一下搭建框架的心得,有什么不对的地方欢饮大家指正。 下面是pom.xml里面的配置!!!<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/......
  • springBoot+mysql实现用户权限控制--系统框架搭建(四)
    上篇文章说了AOP实现上下文的存储,有需要的可以看看,​​AOP实现上下文存储---系统框架搭建(三)​​环境需求:springboot+mysql5.7.16+Lombok1.18.121、需求背景为了实......
  • vSAN 架构下搭建 Oracle RAC
    规划​OracleRAC-A:16核心、16G内存、600G系统盘、80G、80G、500G​OracleRAC-B:16核心、16G内存、600G系统盘、80G、80G、500G创建虚拟机存储策略在vCenterServer中找到......
  • 使用Docker一键搭建FastDFS+Nginx分布式文件服务器
    做过很多项目在图片上传上一直使用的是FastDFS,刚开始得知搭建一个这样的系统非常复杂,所以直接使用了淘淘商城的虚拟机。在后面的项目中,最终选择在在阿里云上自己搭建一个Fas......
  • 跳板机搭建
    ssh_key免密钥登陆ssh-keygen-tdsa-P''-f~/.ssh/id_dsa 发送密钥ssh-copy-id-i.ssh/id_dsa.pub"[email protected]" 登录即执行这里面的脚本(注意要......
  • 一台虚拟机,基于docker搭建大数据HDP集群
    前言好多人问我,这种基于大数据平台的xxxx的毕业设计要怎么做。这个可以参考之前写得关于我大数据毕业设计的文章。这篇文章是将对之前的毕设进行优化。个人觉得可以分为......