index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Component({
  2. externalClasses: [
  3. 'l-class'
  4. ],
  5. options: {
  6. multipleSlots: true // 在组件定义时的选项中启用多slot支持
  7. },
  8. relations: {
  9. '../step/index': {
  10. type: 'child',
  11. linked() {
  12. this._initSteps();
  13. },
  14. unlinked() {
  15. this._initSteps();
  16. }
  17. },
  18. },
  19. properties: {
  20. direction: {
  21. type: String,
  22. value: 'row'
  23. },
  24. activeIndex: {
  25. type: Number,
  26. value: 0
  27. },
  28. color: String,
  29. stepMinHeight: {
  30. type: String,
  31. value: '120'
  32. },
  33. status: {
  34. type: String,
  35. value: 'process'
  36. },
  37. dot: Boolean,
  38. reverse: Boolean
  39. },
  40. observers: {
  41. 'activeIndex': function () {
  42. this._initSteps();
  43. }
  44. },
  45. /**
  46. * 组件的初始数据
  47. */
  48. data: {
  49. },
  50. /**
  51. * 组件的方法列表
  52. */
  53. methods: {
  54. _initSteps() {
  55. const query = wx.createSelectorQuery().in(this);
  56. query.select('.steps-container').boundingClientRect().exec(res => {
  57. let steps = this.getRelationNodes('../step/index');
  58. this.data.length = steps.length;
  59. if (this.data.length > 0) {
  60. steps.forEach((step, index) => {
  61. step.updateDataChange({
  62. index,
  63. ...this.data,
  64. stepsWidth: res[0].width
  65. });
  66. });
  67. }
  68. });
  69. }
  70. }
  71. });