fs-space.vue 907 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <view class="fs-space" :class="{ 'gutter-v': gutter }" :style="{ gap: size }"><slot></slot></view>
  3. </template>
  4. <script>
  5. /**
  6. * 间距组件
  7. * @description 间距组件(设置组件之间的间距)
  8. * @property {String} size 间距大小
  9. * @property {String} direction 间距方向
  10. * @property {String} justify 间距方向
  11. * @property {Boolean} gutter 下边距
  12. */
  13. export default {
  14. name: 'fs-space'
  15. }
  16. </script>
  17. <script setup>
  18. const props = defineProps({
  19. size: {
  20. type: String,
  21. default: '20rpx'
  22. },
  23. direction: {
  24. type: String,
  25. default: 'row',
  26. validator(value) {
  27. return ['row', 'column'].includes(value)
  28. }
  29. },
  30. justify: {
  31. type: String,
  32. default: 'flex-start'
  33. },
  34. gutter: Boolean
  35. })
  36. </script>
  37. <style lang="scss" scoped>
  38. .fs-space {
  39. display: flex;
  40. flex-direction: v-bind(direction);
  41. flex-wrap: wrap;
  42. justify-content: v-bind(justify);
  43. align-items: center;
  44. }
  45. </style>