my-topbar.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="topbar uni-row">
  3. <view class="topbar-left-right uni-row uni-jct">
  4. <uni-icons type="left" class="topbar-ico topbar-ico-back" @click="btnBack"></uni-icons>
  5. <text v-if="showMessage" class="topbar-rule"></text>
  6. </view>
  7. <text class="mcName" v-html="mcName"></text>
  8. <view class="topbar-left-right uni-row uni-jce">
  9. <uni-icons v-if="showMessage" type="notification-filled" class="topbar-ico topbar-ico-message" @click="btnMessage"></uni-icons>
  10. <text v-if="showRule" class="topbar-rule" @click="btnInfo">规则</text>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name:"my-topbar",
  17. props: {
  18. mcName: {
  19. type: String,
  20. default: ""
  21. },
  22. showMessage: {
  23. type: Boolean,
  24. default: false
  25. // default: true
  26. },
  27. showRule: {
  28. type: Boolean,
  29. default: true
  30. // default: true
  31. }
  32. },
  33. emits: ['btnBackClick', 'btnInfoClick', 'btnMessageClick'],
  34. data() {
  35. return {
  36. };
  37. },
  38. methods: {
  39. btnBack() {
  40. this.$emit('btnBackClick');
  41. },
  42. btnInfo() {
  43. this.$emit('btnInfoClick');
  44. },
  45. btnMessage() {
  46. this.$emit('btnMessageClick');
  47. }
  48. }
  49. }
  50. </script>
  51. <style>
  52. .topbar {
  53. width: 92%;
  54. /* padding-top: 2px; */
  55. justify-content: space-between;
  56. }
  57. .topbar-color-default {
  58. color: #5b9100;
  59. }
  60. .topbar-left-right {
  61. min-width: 50px;
  62. max-width: 128rpx;
  63. /* background-color: dimgray; */
  64. }
  65. .topbar-ico { width: 43rpx; height: 43rpx;
  66. /* padding: 0 10rpx; */ color: inherit !important; font-size: 46rpx !important; }
  67. .topbar-ico-back {
  68. padding-right: 10rpx;
  69. }
  70. .topbar-ico-message {
  71. padding-left: 10rpx;
  72. }
  73. .topbar-rule {
  74. /* width: 60rpx; */
  75. padding: 0 10rpx;
  76. font-size: 30rpx;
  77. white-space: nowrap;
  78. }
  79. .mcName {
  80. /* padding: 0 10rpx; */
  81. /* width: 80%; */
  82. font-size: 36rpx;
  83. font-weight: 550;
  84. white-space: nowrap;
  85. overflow: hidden;
  86. /* text-overflow: ellipsis; */
  87. }
  88. </style>