fs-col.vue 959 B

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