<template>
  <van-nav-bar fixed placeholder safe-area-inset-top :title="title || $route.meta.title" left-text="返回" left-arrow
    @click-left="back ? back() : $router.back();">
    <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 lang="less">
.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>