index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/classNames'
  3. baseComponent({
  4. relations: {
  5. '../step/index': {
  6. type: 'child',
  7. observer() {
  8. this.debounce(this.updateCurrent)
  9. },
  10. },
  11. },
  12. properties: {
  13. prefixCls: {
  14. type: String,
  15. value: 'wux-steps',
  16. },
  17. current: {
  18. type: Number,
  19. value: 0,
  20. observer: 'updateCurrent',
  21. },
  22. // status: {
  23. // type: String,
  24. // value: '',
  25. // },
  26. direction: {
  27. type: String,
  28. value: 'horizontal',
  29. },
  30. },
  31. methods: {
  32. updateCurrent() {
  33. const elements = this.getRelationNodes('../step/index')
  34. const { current, direction } = this.data
  35. if (elements.length > 0) {
  36. elements.forEach((element, index) => {
  37. element.updateCurrent({
  38. length: elements.length,
  39. index,
  40. current,
  41. direction,
  42. })
  43. })
  44. }
  45. }
  46. }
  47. })