index.js 771 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { use } from '../utils';
  2. const [sfc, bem] = use('row');
  3. export default sfc({
  4. props: {
  5. type: String,
  6. align: String,
  7. justify: String,
  8. tag: {
  9. type: String,
  10. default: 'div'
  11. },
  12. gutter: {
  13. type: [Number, String],
  14. default: 0
  15. }
  16. },
  17. render(h) {
  18. const { align, justify } = this;
  19. const flex = this.type === 'flex';
  20. const margin = `-${Number(this.gutter) / 2}px`;
  21. const style = this.gutter ? { marginLeft: margin, marginRight: margin } : {};
  22. return (
  23. <this.tag
  24. style={style}
  25. class={bem({
  26. flex,
  27. [`align-${align}`]: flex && align,
  28. [`justify-${justify}`]: flex && justify
  29. })}
  30. >
  31. {this.slots()}
  32. </this.tag>
  33. );
  34. }
  35. });