header.vue 1.93 KB
<template>
    <div class="blk-header-wrap" :class="class">
        <div class="blk-header">
            <div class="blk-header-left">
                <slot name="left">
                    <i class="icon icon-left" @click="goBack"></i>
                </slot>
            </div>
            <div class="blk-header-right">
                <slot name="right"></slot>
            </div>
            <div class="blk-header-main">
                <span class="blk-header-title">{{title}}</span>
            </div>
        </div>
        <div class="blk-header-gap"></div>
    </div>
</template>
<script>
    const yoho = require('yoho');

    module.exports = {
        props: ['title', 'class'],
        methods: {
            goBack() {
                yoho.goBack({}, function() {}, function() {});
            }
        }
    };
</script>
<style>
    .blk-header {
        box-sizing: content-box;
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        z-index: 210;
        padding: 20px 30px;
        height: 70px;
        max-width: 750px;
        margin-left: auto;
        margin-right: auto;
        line-height: 70px;
        font-size: 48px;
        background-color: #fff;
        color: #000;

        .icon,
        .blk-header-title {
            vertical-align: middle;
        }
    }

    .blk-header-main {
        display: block;
        text-align: center;
        margin-left: auto;
        margin-right: auto;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .blk-header-left {
        float: left;
    }

    .blk-header-right {
        float: right;

        .icon {
            margin-left: 30px;
        }
    }

    .blk-header-gap {
        height: 100px;
        background-color: transparent;
    }

    .app.ios {
        .blk-header {
            padding-top: 60px;
        }

        .blk-header-gap {
            height: calc(70 + 60 + 10)px;
        }
    }
</style>