index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { VantComponent } from '../common/component';
  2. import { link } from '../mixins/link';
  3. import { button } from '../mixins/button';
  4. import { openType } from '../mixins/open-type';
  5. VantComponent({
  6. mixins: [link, button, openType],
  7. relation: {
  8. type: 'ancestor',
  9. name: 'goods-action',
  10. linked(parent) {
  11. this.parent = parent;
  12. }
  13. },
  14. props: {
  15. text: String,
  16. color: String,
  17. loading: Boolean,
  18. disabled: Boolean,
  19. type: {
  20. type: String,
  21. value: 'danger'
  22. }
  23. },
  24. mounted() {
  25. this.updateStyle();
  26. },
  27. methods: {
  28. onClick(event) {
  29. this.$emit('click', event.detail);
  30. this.jumpLink();
  31. },
  32. updateStyle() {
  33. const { parent } = this;
  34. const { children = [] } = parent;
  35. const index = children.indexOf(this);
  36. const { length } = children;
  37. let isFirst = false;
  38. let isLast = false;
  39. if (index === 0) {
  40. isFirst = true;
  41. }
  42. if (index === length - 1) {
  43. isLast = true;
  44. }
  45. this.setData({
  46. isFirst,
  47. isLast
  48. });
  49. }
  50. }
  51. });