index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Component({
  2. externalClasses: ['i-class'],
  3. relations: {
  4. '../tab/index': {
  5. type: 'child',
  6. linked () {
  7. this.changeCurrent();
  8. },
  9. linkChanged () {
  10. this.changeCurrent();
  11. },
  12. unlinked () {
  13. this.changeCurrent();
  14. }
  15. }
  16. },
  17. properties: {
  18. current: {
  19. type: String,
  20. value: '',
  21. observer: 'changeCurrent'
  22. },
  23. color: {
  24. type: String,
  25. value: ''
  26. },
  27. scroll: {
  28. type: Boolean,
  29. value: false
  30. },
  31. fixed: {
  32. type: Boolean,
  33. value: false
  34. }
  35. },
  36. methods: {
  37. changeCurrent (val = this.data.current) {
  38. let items = this.getRelationNodes('../tab/index');
  39. const len = items.length;
  40. if (len > 0) {
  41. items.forEach(item => {
  42. item.changeScroll(this.data.scroll);
  43. item.changeCurrent(item.data.key === val);
  44. item.changeCurrentColor(this.data.color);
  45. });
  46. }
  47. },
  48. emitEvent (key) {
  49. this.triggerEvent('change', { key });
  50. }
  51. }
  52. });