index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { link } from '../mixins/link';
  2. import { VantComponent } from '../common/component';
  3. VantComponent({
  4. relation: {
  5. name: 'grid',
  6. type: 'ancestor',
  7. current: 'grid-item',
  8. },
  9. classes: ['content-class', 'icon-class', 'text-class'],
  10. mixins: [link],
  11. props: {
  12. icon: String,
  13. iconColor: String,
  14. dot: Boolean,
  15. info: null,
  16. badge: null,
  17. text: String,
  18. useSlot: Boolean,
  19. },
  20. data: {
  21. viewStyle: '',
  22. },
  23. mounted() {
  24. this.updateStyle();
  25. },
  26. methods: {
  27. updateStyle() {
  28. if (!this.parent) {
  29. return;
  30. }
  31. const { data, children } = this.parent;
  32. const {
  33. columnNum,
  34. border,
  35. square,
  36. gutter,
  37. clickable,
  38. center,
  39. direction,
  40. iconSize,
  41. } = data;
  42. this.setData({
  43. center,
  44. border,
  45. square,
  46. gutter,
  47. clickable,
  48. direction,
  49. iconSize,
  50. index: children.indexOf(this),
  51. columnNum,
  52. });
  53. },
  54. onClick() {
  55. this.$emit('click');
  56. this.jumpLink();
  57. },
  58. },
  59. });