<!--
 * 严肃声明：
 * 开源版本请务必保留此注释头信息，若删除我方将保留所有法律责任追究！
 * 本系统已申请软件著作权，受国家版权局知识产权以及国家计算机软件著作权保护！
 * 可正常分享和学习源码，不得用于违法犯罪活动，违者必究！
 * Copyright (c) 2020 陈尼克 all rights reserved.
 * 版权所有，侵权必究！
 *
-->

<template>
  <div>
    <van-sticky>
      <header class="header">
        <div class="iconColorLeft">
          <van-icon @click="to" name="arrow-left" />
        </div>
        <span>{{ text }}</span>
        <!-- <van-icon name="bars" class="iconColorRight" /> -->
        <div class="iconColorRight">
          <slot name="right"></slot>
        </div>
      </header>
    </van-sticky>
  </div>
</template>

<script>
export default {
  props: {
    text: {
      default: "未知",
      type: String,
    },
    customBack: {
      type: Function,
    },
  },
  data() {
    return {};
  },
  mounted() {},
  methods: {
    /* 左侧图标跳转方法 */
    to() {
      if (this.customBack) {
        this.customBack();
      } else {
        history.go(-1);
      }
    },
  },
};
</script>
<style lang="less" scoped>
.header {
  width: 100%;
  height: 1.5rem;
  background: #2980f7;
  text-align: center;
  line-height: 1.5rem;
}
.iconColorLeft {
  color: white;
  position: absolute;
  top: 0%;
  left: 5%;
  .van-icon {
    transform: scale(2);
    vertical-align: middle;
  }
}
.header span {
  color: white;
  font-size: 16px;
  margin: auto;
  font-family: "Microsoft YaHei";
}
.header .iconColorRight {
  color: white;
  position: absolute;
  right: 5%;
  top: 0;
  font-size: 12px;
  vertical-align: middle;
}
</style>
