customHeader.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="custom-header" :style="{ background: bgColor, color: titleColor }">
  3. <div class="home" @click="goHome" v-if="showHome">
  4. <el-icon size="20" class="icon" :color="iconColor"><HomeFilled /></el-icon>
  5. </div>
  6. <div class="back" @click="goback" v-else-if="!isClose">
  7. <el-icon class="icon" :color="iconColor"><ArrowLeftBold /></el-icon>
  8. </div>
  9. <div class="close" @click="close" v-else-if="isClose && showClose">
  10. <el-icon class="icon" :color="iconColor"><CloseBold /></el-icon>
  11. </div>
  12. <div class="title">{{name}}</div>
  13. </div>
  14. </template>
  15. <script setup>
  16. import { useRouter} from "vue-router";
  17. import { ArrowLeftBold, CloseBold, HomeFilled } from "@element-plus/icons-vue";
  18. const router = useRouter();
  19. const props = defineProps({
  20. name:{
  21. type:String,
  22. defalut:''
  23. },
  24. bgColor:{
  25. type:String,
  26. defalut:'#151516'
  27. },
  28. /** 返回/关闭图标颜色 */
  29. iconColor: {
  30. type: String,
  31. default: "#fff",
  32. },
  33. /** 标题文字颜色 */
  34. titleColor: {
  35. type: String,
  36. default: "#FFFFFF",
  37. },
  38. isGoBack:{
  39. type:Boolean,
  40. defalut:false
  41. },
  42. isClose:{
  43. type:Boolean,
  44. defalut:false
  45. },
  46. showClose:{
  47. type:Boolean,
  48. defalut: true
  49. },
  50. /** 分享进页:左侧显示首页图标,点击进 growth_report */
  51. showHome: {
  52. type: Boolean,
  53. default: false,
  54. },
  55. })
  56. const emit = defineEmits(['close', "goback", "home"])
  57. const goback = () => {
  58. if(!props.isGoBack){
  59. router.go(-1);
  60. }else{
  61. emit('goback')
  62. }
  63. };
  64. const close = () => {
  65. emit('close')
  66. }
  67. const goHome = () => {
  68. emit("home");
  69. router.replace("/growth_report");
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .custom-header{
  74. background: #151516;
  75. width: 100%;
  76. height: 40px;
  77. font-size: 17px;
  78. display: flex;
  79. justify-content: center;
  80. align-items: center;
  81. position: relative;
  82. z-index: 12;
  83. .back,.close,.home{
  84. display: flex;
  85. align-items: center;
  86. color: #fff;
  87. position: absolute;
  88. left: 12px;
  89. z-index: 10;
  90. }
  91. .title{
  92. font-weight: 600;
  93. font-size: 17px;
  94. }
  95. }
  96. </style>