index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { VantComponent } from '../common/component';
  2. import { addUnit } from '../common/utils';
  3. VantComponent({
  4. relation: {
  5. name: 'grid-item',
  6. type: 'descendant',
  7. current: 'grid',
  8. },
  9. props: {
  10. square: {
  11. type: Boolean,
  12. observer: 'updateChildren',
  13. },
  14. gutter: {
  15. type: [Number, String],
  16. value: 0,
  17. observer: 'updateChildren',
  18. },
  19. clickable: {
  20. type: Boolean,
  21. observer: 'updateChildren',
  22. },
  23. columnNum: {
  24. type: Number,
  25. value: 4,
  26. observer: 'updateChildren',
  27. },
  28. center: {
  29. type: Boolean,
  30. value: true,
  31. observer: 'updateChildren',
  32. },
  33. border: {
  34. type: Boolean,
  35. value: true,
  36. observer: 'updateChildren',
  37. },
  38. direction: {
  39. type: String,
  40. observer: 'updateChildren',
  41. },
  42. iconSize: {
  43. type: String,
  44. observer: 'updateChildren',
  45. },
  46. },
  47. data: {
  48. viewStyle: '',
  49. },
  50. created() {
  51. const { gutter } = this.data;
  52. if (gutter) {
  53. this.setData({
  54. viewStyle: `padding-left: ${addUnit(gutter)}`,
  55. });
  56. }
  57. },
  58. methods: {
  59. updateChildren() {
  60. this.children.forEach((child) => {
  61. child.updateStyle();
  62. });
  63. },
  64. },
  65. });