tooltip.vue 973 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <view class="tips">
  3. <view class="tips_title" v-if="show">{{ t(title) }}</view>
  4. <view class="tip_cont">
  5. <slot></slot>
  6. </view>
  7. </view>
  8. </template>
  9. <script setup>
  10. import { t } from "@/locale"
  11. const props = defineProps({
  12. title: {
  13. type: String,
  14. default: ''
  15. },
  16. show: Boolean
  17. })
  18. </script>
  19. <style lang="less" scoped>
  20. .tips {
  21. position: relative;
  22. .tips_title {
  23. max-width: 80vw;
  24. background-color: #303133;
  25. color: var(--light);
  26. padding: 10rpx 22rpx;
  27. border-radius: 8rpx;
  28. font-size: 24rpx;
  29. position: absolute;
  30. top: -60rpx;
  31. left: 50%;
  32. transform: translateX(-50%);
  33. width: fit-content;
  34. text-wrap: nowrap;
  35. &::before {
  36. content: '';
  37. position: absolute;
  38. left: 50%;
  39. bottom: -12rpx;
  40. transform: translateX(-50%);
  41. border-left: 14rpx solid transparent;
  42. border-right: 14rpx solid transparent;
  43. border-top: 14rpx solid #303133;
  44. }
  45. }
  46. }
  47. </style>