<template>
  <div class="pageTitle" :style="`margin-bottom: ${marginBottom}px;background-color: ${backgroundColor}`">
    <div class="title">
      <div class="font" v-if="typeof title === 'string'">{{ title }}</div>
      <ul v-else class="flex" style="align-items: center;">
        <el-button @click="handleClick(item,index)" :type="active == index ? 'primary':''" v-for="(item, index) in title" :key="index">{{ item }}</el-button>
      </ul>
    </div>
    <div class="cnetr">
      <slot name="center"></slot>
    </div>
    <div class="right">
      <slot> </slot>
    </div>
  </div>
</template>

<script setup>
import { ref ,defineEmits} from 'vue';
defineProps({
  title: {
    type: String || Array,
    default: "" || []
  },
  active:{
    type: Number,
    default: 0
  }, //下标
  marginBottom: {
    type: Number,
    default: 0
  },
  backgroundColor: {
    type: String,
    default: "rgb(255, 255, 255, 0)"
  }
});
const emit = defineEmits(['change','update:active']);
function handleClick (item,index){ 
  emit('update:active',index);
  emit('change',item)
}
</script>
 
<style lang = "scss" scoped>
.pageTitle {
  width: 100%;
  padding: 10px 0;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
  .title {
    display: flex;
    margin: auto 0;
    .icon {
      margin: auto 0;
    }
    .font {
      vertical-align: middle;
      font-size: 18px;
    }
  }
}

</style>