• vue 顶部公共组件封装


    <template>
    <div class="top-header">
    <div
    class="top-nav flex flex--justify-content--space-between flex--align-items--center"
    :class="{'bg-white': !isTransparent}" >
    <!-- 左 -->
    <div class="left-img flex flex--justify-content--start">
    <div v-if="showBack" @click="back">
    <img v-if="!isTransparent" :src="blackImg" alt />
    <img v-else :src="whiteImg" alt />
    </div>
    </div>

    <!-- 中 -->
    <div class="top-center">
    <h2
    v-if="title"
    class="ellipsis-1"
    :class="{'black': !isTransparent, 'white': isTransparent}"
    >{{title}}</h2>
    </div>

    <!-- 右 -->
    <div class="right-opart flex flex--justify-content--end">
    <slot name="right"></slot>
    </div>
    </div>
    <div v-if="!isTransparent" class="clear-position"></div>
    </div>
    </template>
    <script>
    import whiteImg from "../../../static/img/common/white-left.png";//白色返回图标
    import blackImg from "../../../static/img/common/black-left.png";//黑色返回图标
    export default {
    props: [
    "isTransparent", // 导航组件是否透明
    "title", // 导航的标题,不传不显示
    "showBack" // 是否显示返回按钮
    ],
    data() {
    return {
    whiteImg,
    blackImg
    };
    },
    methods: {
    /**
    * 返回
    */
    back() {
    this.$router.go(-1);
    }
    }
    };
    </script>
    <style scoped>
    .top-header {

    }
    .right-opart,
    .left-img {
    25%;
    }
    .top-center {
    font-weight: 500;
    font-family: PingFangSC;
    }

    .clear-position,
    .top-nav {
    /* height: 0.8rem; */
    padding: 0 0.3rem;
    box-sizing: border-box;
    height: 1.12rem;
    /* background-color: #FFFFFF; */
    /* border-bottom: 1px solid #f2f4f7; */
    }
    .top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    /* padding-top: 0.32rem; */
    }
    .left-img img {
    0.24rem;
    height: 0.44rem;
    }
    .top-center h2 {
    font-size: 0.34rem;
    }
    .top-center h2.black {
    color: #333;
    }
    .top-center h2.white {
    color: #fff;
    }
    </style>

  • 相关阅读:
    09-13练习
    IDEA设置项目文件自动Add到Svn/Git
    虚拟机启动项目时报错
    微服务调用时报错
    查询每个月每一天的访问量
    在IDEA中关于项目java版本问题
    复习宝典之设计模式
    复习宝典之Maven项目管理
    复习宝典之Mysql数据库
    复习宝典之Redis
  • 原文地址:https://www.cnblogs.com/fanqiuzhuji/p/12610859.html
Copyright © 2020-2023  润新知