index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 { children = [] } = this.parent;
  34. const index = children.indexOf(this);
  35. this.setData({
  36. isFirst: index === 0,
  37. isLast: index === children.length - 1
  38. });
  39. }
  40. }
  41. });