index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { createNamespace } from '../utils';
  2. import { ChildrenMixin } from '../mixins/relation';
  3. var _createNamespace = createNamespace('col'),
  4. createComponent = _createNamespace[0],
  5. bem = _createNamespace[1];
  6. export default createComponent({
  7. mixins: [ChildrenMixin('vanRow')],
  8. props: {
  9. span: [Number, String],
  10. offset: [Number, String],
  11. tag: {
  12. type: String,
  13. default: 'div'
  14. }
  15. },
  16. computed: {
  17. style: function style() {
  18. var index = this.index;
  19. var _ref = this.parent || {},
  20. spaces = _ref.spaces;
  21. if (spaces && spaces[index]) {
  22. var _spaces$index = spaces[index],
  23. left = _spaces$index.left,
  24. right = _spaces$index.right;
  25. return {
  26. paddingLeft: left ? left + "px" : null,
  27. paddingRight: right ? right + "px" : null
  28. };
  29. }
  30. }
  31. },
  32. methods: {
  33. onClick: function onClick(event) {
  34. this.$emit('click', event);
  35. }
  36. },
  37. render: function render() {
  38. var _bem;
  39. var h = arguments[0];
  40. var span = this.span,
  41. offset = this.offset;
  42. return h(this.tag, {
  43. "style": this.style,
  44. "class": bem((_bem = {}, _bem[span] = span, _bem["offset-" + offset] = offset, _bem)),
  45. "on": {
  46. "click": this.onClick
  47. }
  48. }, [this.slots()]);
  49. }
  50. });