index.js 987 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. var _component = require("../common/component");
  3. (0, _component.VantComponent)({
  4. relation: {
  5. name: "col",
  6. type: "descendant",
  7. current: "row",
  8. linked: function linked(target) {
  9. if (this.data.gutter) {
  10. target.setGutter(this.data.gutter);
  11. }
  12. }
  13. },
  14. props: {
  15. gutter: {
  16. type: Number,
  17. observer: "setGutter"
  18. }
  19. },
  20. data: {
  21. viewStyle: ""
  22. },
  23. mounted: function mounted() {
  24. if (this.data.gutter) {
  25. this.setGutter();
  26. }
  27. },
  28. methods: {
  29. setGutter: function setGutter() {
  30. var _this = this;
  31. var gutter = this.data.gutter;
  32. var margin = "-".concat(Number(gutter) / 2, "px");
  33. var viewStyle = gutter ? "margin-right: ".concat(margin, "; margin-left: ").concat(margin, ";") : "";
  34. this.setData({
  35. viewStyle: viewStyle
  36. });
  37. this.getRelationNodes("../col/index").forEach(function (col) {
  38. col.setGutter(_this.data.gutter);
  39. });
  40. }
  41. }
  42. });