index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view :class="getClasses()">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script lang="ts">
  7. import { computed, provide } from 'vue';
  8. import { createComponent } from '@/utils/create';
  9. const { componentName, create } = createComponent('row');
  10. export default create({
  11. props: {
  12. type: {
  13. type: String,
  14. default: ''
  15. },
  16. gutter: {
  17. type: [String, Number],
  18. default: ''
  19. },
  20. justify: {
  21. type: String,
  22. default: 'start'
  23. },
  24. align: {
  25. type: String,
  26. default: 'flex-start'
  27. },
  28. flexWrap: {
  29. type: String,
  30. default: 'nowrap'
  31. }
  32. },
  33. setup(props) {
  34. const prefixCls = componentName;
  35. provide('gutter', props.gutter);
  36. const getClass = (prefix: string, type: string) => {
  37. return prefix
  38. ? type
  39. ? `nut-row-${prefix}-${type}`
  40. : ''
  41. : `nut-row-${type}`;
  42. };
  43. const getClasses = () => {
  44. return `
  45. ${getClass('', props.type)}
  46. ${getClass('justify', props.justify)}
  47. ${getClass('align', props.align)}
  48. ${getClass('flex', props.flexWrap)}
  49. ${prefixCls}
  50. `;
  51. };
  52. return {
  53. getClasses
  54. };
  55. }
  56. });
  57. </script>
  58. <style lang="scss">
  59. @import 'index.scss';
  60. </style>