tab-popup.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="tab-popup">
  3. <view class="popup-box" v-if="show">
  4. <view class="item" :class="{ active: selectedItem === item }" @click="selectItem(item)" v-for="(item, index) in items" :key="index">
  5. {{ item }}
  6. </view>
  7. </view>
  8. <view class="popup-mask" v-if="show" @click="close"></view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. show: {
  15. type: Boolean,
  16. default: false
  17. },
  18. items: {
  19. type: Array,
  20. default: () => []
  21. },
  22. selectedItem: {
  23. type: String,
  24. default: ''
  25. }
  26. },
  27. methods: {
  28. selectItem(item) {
  29. this.$emit('select', item)
  30. this.$emit('update:show', false)
  31. },
  32. close() {
  33. this.$emit('update:show', false)
  34. }
  35. }
  36. }
  37. </script>
  38. <style lang="scss" scoped>
  39. .tab-popup {
  40. .popup-mask {
  41. position: fixed;
  42. top: 0;
  43. left: 0;
  44. right: 0;
  45. bottom: 0;
  46. background: rgba(0, 0, 0, 0.3);
  47. z-index: 99;
  48. }
  49. .popup-box {
  50. position: absolute;
  51. top: 100%;
  52. left: 0;
  53. right: 0;
  54. display: flex;
  55. padding: 32rpx;
  56. background: #FFFFFF;
  57. border-radius: 0 0 40rpx 40rpx;
  58. z-index: 100;
  59. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  60. .item {
  61. padding: 14rpx 32rpx;
  62. height: 72rpx;
  63. box-sizing: border-box;
  64. background: #F7F8FA;
  65. border-radius: 70rpx;
  66. font-size: 28rpx;
  67. color: #333;
  68. flex-wrap: wrap;
  69. margin-right: 24rpx;
  70. cursor: pointer;
  71. transition: all 0.2s;
  72. border: 2rpx solid transparent;
  73. &.active {
  74. color: #388BFF;
  75. background: rgba(56,139,255,0.15);
  76. border-color: #388BFF;
  77. }
  78. &:last-child {
  79. margin-right: 0;
  80. }
  81. }
  82. }
  83. }
  84. </style>