bubble-tip.vue 792 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <view>
  3. <view class="speech-bubble" :class="direction">
  4. <text>{{msg}}</text>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. name: "bubble-tip",
  11. props: {
  12. msg: {
  13. type: String
  14. }
  15. },
  16. data() {
  17. return {
  18. direction: "speech-bubble-bottom"
  19. };
  20. }
  21. }
  22. </script>
  23. <style scoped>
  24. .speech-bubble {
  25. position: relative;
  26. background-color: #292929;
  27. width: max-content;
  28. min-width: 100rpx;
  29. /* 垂直居中 */
  30. color: white;
  31. text-align: center;
  32. border-radius: 10px;
  33. padding: 10rpx 10rpx 10rpx 10rpx;
  34. }
  35. .speech-bubble:after {
  36. content: '';
  37. position: absolute;
  38. width: 0;
  39. height: 0;
  40. border: 15rpx solid;
  41. }
  42. .speech-bubble-bottom:after {
  43. border-top-color: #292929;
  44. top: 100%;
  45. left: 50%;
  46. margin-left: -15rpx;
  47. }
  48. </style>