<template>
    <!-- -->
    <van-nav-bar fixed :title="$isWechat() ? '' : title || $route.meta.title" :safe-area-inset-top="true" placeholder
        left-arrow left-text="返回" @click-left="back ? back() : $router.back();"
        :class="$isWechat() ? 'wechat-nav' : ''">
        <template #right>
            <slot v-if="$slots.right" name="right" />
            <van-icon v-else-if="!hideHome" name="wap-home-o" size="18" @click="$router.replace('/')" />
        </template>
    </van-nav-bar>
    <slot />
</template>

<script>
export default {
    props: [
        'back', 'hideHome', 'title'
    ],
    watch: {
        title(val, old) {
            if (val)
                document.title = val;
        },
    },
    mounted() {
        setTimeout(() => {
            if (this.title)
                document.title = this.title;
        }, 50);
    },
    data() {
        return {

        }
    },
    methods: {

    }
}
</script>
<style>
.van-nav-bar .van-nav-bar__text,
.van-nav-bar .van-icon {
    color: #000 !important;
}

.wechat-nav {
    .van-safe-area-top {
        background: var(--base-nav-bar-bg-color);
    }

    .van-nav-bar .van-nav-bar__text,
    .van-nav-bar .van-icon {
        color: var(--base-nav-bar-color) !important;
    }
}
</style>