index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. component_1.VantComponent({
  5. relation: {
  6. name: 'col',
  7. type: 'descendant',
  8. linked: function (target) {
  9. if (this.data.gutter) {
  10. target.setGutter(this.data.gutter);
  11. }
  12. }
  13. },
  14. props: {
  15. gutter: Number
  16. },
  17. watch: {
  18. gutter: 'setGutter'
  19. },
  20. mounted: function () {
  21. if (this.data.gutter) {
  22. this.setGutter();
  23. }
  24. },
  25. methods: {
  26. setGutter: function () {
  27. var _this = this;
  28. var gutter = this.data.gutter;
  29. var margin = "-" + Number(gutter) / 2 + "px";
  30. var style = gutter
  31. ? "margin-right: " + margin + "; margin-left: " + margin + ";"
  32. : '';
  33. this.set({ style: style });
  34. this.getRelationNodes('../col/index').forEach(function (col) {
  35. col.setGutter(_this.data.gutter);
  36. });
  37. }
  38. }
  39. });