index.js 952 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { VantComponent } from '../common/component';
  2. import { GREEN } from '../common/color';
  3. VantComponent({
  4. props: {
  5. icon: String,
  6. steps: Array,
  7. active: Number,
  8. direction: {
  9. type: String,
  10. value: 'horizontal'
  11. },
  12. activeColor: {
  13. type: String,
  14. value: GREEN
  15. }
  16. },
  17. watch: {
  18. steps: 'formatSteps',
  19. active: 'formatSteps'
  20. },
  21. created: function created() {
  22. this.formatSteps();
  23. },
  24. methods: {
  25. formatSteps: function formatSteps() {
  26. var _this = this;
  27. var steps = this.data.steps;
  28. steps.forEach(function (step, index) {
  29. step.status = _this.getStatus(index);
  30. });
  31. this.set({
  32. steps: steps
  33. });
  34. },
  35. getStatus: function getStatus(index) {
  36. var active = this.data.active;
  37. if (index < active) {
  38. return 'finish';
  39. } else if (index === active) {
  40. return 'process';
  41. }
  42. return '';
  43. }
  44. }
  45. });