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

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

    .header-main {
        display: block;
        text-align: center;
        margin-left: auto;
        margin-right: auto;
    }

    .header-left {
        float: left;
    }

    .header-right {
        float: right;
        .icon {
            margin-left: 30px;
        }
    }

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

    .app.ios {
        .header {
            padding-top: 50px;
        }
        .header-gap {
            height: calc(70 + 50 + 10)px;
        }
    }
</style>