index.js 1.3KB

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