index.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <view class="i-class i-collapse" @collapse="clickfn">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. showContent: ''
  11. };
  12. },
  13. unicomGroup: ['collapse-item'],
  14. externalClasses: ['i-class'],
  15. relations: {
  16. '../collapse-item/index': {
  17. type: 'child'
  18. }
  19. },
  20. props: {
  21. name: String,
  22. accordion: Boolean
  23. },
  24. methods: {
  25. clickfn(e) {
  26. const params = e.detail;
  27. const allList = this.getRelationNodes('collapse-item');
  28. allList.forEach((item) => {
  29. if (params.name === item.data.name) {
  30. item.setData({
  31. showContent: 'i-collapse-item-show-content'
  32. });
  33. } else {
  34. item.setData({
  35. showContent: ''
  36. });
  37. }
  38. });
  39. }
  40. },
  41. created: function () {}
  42. };
  43. </script>
  44. <style>
  45. @import './index.css';
  46. </style>