index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. Component({
  2. externalClasses: ['i-class-content', 'i-class-title', 'i-class'],
  3. relations: {
  4. '../collapse/index': {
  5. type: 'parent',
  6. linked: function (target) {
  7. const options = {
  8. accordion: target.data.accordion
  9. }
  10. if (target.data.name === this.data.name) {
  11. options.showContent = 'i-collapse-item-show-content';
  12. }
  13. this.setData(options);
  14. }
  15. }
  16. },
  17. properties: {
  18. title: String,
  19. name: String
  20. },
  21. data: {
  22. showContent: '',
  23. accordion: false
  24. },
  25. options: {
  26. multipleSlots: true
  27. },
  28. methods: {
  29. trigger(e) {
  30. const data = this.data;
  31. if (data.accordion) {
  32. this.triggerEvent('collapse', {name: data.name}, {composed: true, bubbles: true});
  33. } else {
  34. this.setData({
  35. showContent: data.showContent ? '' : 'i-collapse-item-show-content'
  36. });
  37. }
  38. },
  39. }
  40. });