index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view :class="'van-grid custom-class ' + (border && !gutter ? 'van-hairline--top' : '')" :style="viewStyle">
  3. <slot />
  4. </view>
  5. </template>
  6. <script>
  7. 'use strict';
  8. Object.defineProperty(exports, '__esModule', {
  9. value: true
  10. });
  11. var component_1 = require('../common/component');
  12. var utils_1 = require('../common/utils');
  13. component_1.VantComponent({
  14. relation: {
  15. name: 'grid-item',
  16. type: 'descendant',
  17. current: 'grid'
  18. },
  19. props: {
  20. square: {
  21. type: Boolean,
  22. observer: 'updateChildren'
  23. },
  24. gutter: {
  25. type: [Number, String],
  26. value: 0,
  27. observer: 'updateChildren'
  28. },
  29. clickable: {
  30. type: Boolean,
  31. observer: 'updateChildren'
  32. },
  33. columnNum: {
  34. type: Number,
  35. value: 4,
  36. observer: 'updateChildren'
  37. },
  38. center: {
  39. type: Boolean,
  40. value: true,
  41. observer: 'updateChildren'
  42. },
  43. border: {
  44. type: Boolean,
  45. value: true,
  46. observer: 'updateChildren'
  47. },
  48. direction: {
  49. type: String,
  50. observer: 'updateChildren'
  51. },
  52. iconSize: {
  53. type: String,
  54. observer: 'updateChildren'
  55. }
  56. },
  57. data: {
  58. viewStyle: ''
  59. },
  60. created: function () {
  61. var gutter = this.gutter;
  62. if (gutter) {
  63. this.setData({
  64. viewStyle: 'padding-left: ' + utils_1.addUnit(gutter)
  65. });
  66. }
  67. },
  68. methods: {
  69. updateChildren: function () {
  70. this.children.forEach(function (child) {
  71. child.updateStyle();
  72. });
  73. }
  74. }
  75. });
  76. </script>
  77. <style>
  78. @import './index.css';
  79. </style>