fs-col.vue 725 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <view class="fs-col" :class="['fs-col-' + span,{gutter}]" :style="styleStr">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script setup>
  7. import { computed, toRefs, inject } from 'vue'
  8. const props = defineProps({
  9. span: {
  10. type: [Number, String],
  11. default: 12
  12. },
  13. gutter: Boolean
  14. })
  15. const rowGap = inject('rowGap')
  16. const styleStr = computed(() => {
  17. const padding = parseInt(rowGap) / 2
  18. return padding ? `padding-left: ${padding}rpx;padding-right: ${padding}rpx;` : ''
  19. })
  20. </script>
  21. <style lang="scss" scoped>
  22. @use "sass:math";
  23. .fs-col {
  24. float: left;
  25. &.gutter {
  26. margin-bottom: var(--gutter-v);
  27. }
  28. }
  29. @for $i from 1 through 12 {
  30. .fs-col-#{$i} {
  31. width: math.div(100%, 12) * $i;
  32. }
  33. }
  34. </style>