SFilterWrap2.js 893 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const e = `<template>
  2. <div class="filter-wrap" :class="props.type">
  3. <slot />
  4. </div>
  5. </template>
  6. <script setup>
  7. import { onMounted } from 'vue'
  8. const props = defineProps({
  9. // 统一子项标签宽度,单位 px
  10. labelWidth: {
  11. type: Number,
  12. default: 70
  13. },
  14. // filter-more:更多筛选区(紧凑样式)
  15. type: {
  16. type: String,
  17. default: 'filter'
  18. }
  19. })
  20. onMounted(() => {
  21. const labels = document.querySelectorAll('.filter-item .label')
  22. labels.forEach((i) => {
  23. i.style.width = props.labelWidth + 'px'
  24. })
  25. if (props.type && props.type === 'filter-more') {
  26. const items = document.querySelectorAll(\`.filter-more .filter-item\`)
  27. items.forEach((i) => {
  28. i.style.marginBottom = '10px'
  29. })
  30. }
  31. })
  32. <\/script>
  33. <style lang="less" scoped>
  34. .filter-wrap {
  35. display: flex;
  36. flex-wrap: wrap;
  37. gap: 10px;
  38. }
  39. </style>
  40. `;
  41. export {
  42. e as default
  43. };