customHeader.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="custom-header" :style="{background:bgColor}">
  3. <div class="back" @click="goback" v-if="!isClose">
  4. <el-icon class="icon" color="rgba(0, 0, 0, 0.9)"><ArrowLeftBold /></el-icon>
  5. </div>
  6. <div class="close" @click="close" v-if="isClose && showClose">
  7. <el-icon class="icon" color="rgba(0, 0, 0, 0.9)"><CloseBold /></el-icon>
  8. </div>
  9. <div class="title">{{name}}</div>
  10. </div>
  11. </template>
  12. <script setup>
  13. import { ref } from "vue";
  14. import { useRouter} from "vue-router";
  15. const router = useRouter();
  16. const props = defineProps({
  17. name:{
  18. type:String,
  19. defalut:''
  20. },
  21. bgColor:{
  22. type:String,
  23. defalut:'#fff'
  24. },
  25. isGoBack:{
  26. type:Boolean,
  27. defalut:false
  28. },
  29. isClose:{
  30. type:Boolean,
  31. defalut:false
  32. },
  33. showClose:{
  34. type:Boolean,
  35. defalut: true
  36. }
  37. })
  38. const emit = defineEmits(['close', "goback"])
  39. const goback = () => {
  40. if(!props.isGoBack){
  41. router.go(-1);
  42. }else{
  43. emit('goback')
  44. }
  45. };
  46. const close = () => {
  47. emit('close')
  48. }
  49. </script>
  50. <style lang="scss" scoped>
  51. .custom-header{
  52. background: #fff;
  53. width: 100%;
  54. height: 40px;
  55. font-size: 17px;
  56. display: flex;
  57. justify-content: center;
  58. align-items: center;
  59. position: relative;
  60. z-index: 12;
  61. .back,.close{
  62. display: flex;
  63. align-items: center;
  64. color: #656565;
  65. position: absolute;
  66. left: 12px;
  67. z-index: 10;
  68. }
  69. .title{
  70. font-weight: bold;
  71. }
  72. }
  73. </style>