<template>
  <div class="page-header">
    <div class="page-header-back-container" @click="onBack">
      <i class="el-icon-back"></i>
      <div class="page-header-title">
        <slot name="title">{{ title }}</slot>
      </div>
    </div>
    <div class="page-header-content">
      <slot name="content">{{ content }}</slot>
    </div>
    <div class="page-header-right">
      <slot name="right"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PageHeader',

  props: {
    title: {
      type: String,
      default: "返回"
    },
    content: String
  },

  methods:{
    onBack() {
      this.$emit('back');
      this.$router.back()
    }
  }
};
</script>

<style scoped lang="scss">
.page-header {
  display: flex;
  align-items: center;
  position: relative;
  justify-content: center;
  margin-bottom: 30px;

  .page-header-back-container {
    display: flex;
    align-items: center;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    cursor: pointer;

    .page-header-title {
      font-size: 16px;
      color: #303133;
      margin-left: 10px;
    }
  }

  .page-header-content {
    font-size: 20px;
    color: #303133;
  }

  .page-header-right {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
  }
}
</style>
