index.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <!-- components/agent-ui/collapsibleCard/index.wxml -->
  3. <view>
  4. <view @tap="changeCollapsedStatus" style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px">
  5. <slot name="title"></slot>
  6. <image
  7. src="/static/components/agent-ui/imgs/arrow.svg"
  8. mode="aspectFill"
  9. :style="'width: 16px;height: 16px;transform: rotate(' + (collapsedStatus ? 0 : 180) + 'deg);'"
  10. />
  11. </view>
  12. <block v-if="collapsedStatus">
  13. <slot name="content"></slot>
  14. </block>
  15. </view>
  16. </template>
  17. <script>
  18. // components/agent-ui/collapsibleCard/index.js
  19. export default {
  20. data() {
  21. return {
  22. collapsedStatus: false
  23. };
  24. },
  25. /**
  26. * 组件的属性列表
  27. */
  28. props: {
  29. initStatus: {
  30. type: Boolean,
  31. default: false
  32. }
  33. },
  34. mounted() {
  35. // 处理小程序 attached 生命周期
  36. this.attached();
  37. },
  38. /**
  39. * 组件的方法列表
  40. */
  41. methods: {
  42. attached() {
  43. this.setData({
  44. collapsedStatus: this.initStatus
  45. });
  46. },
  47. changeCollapsedStatus: function () {
  48. this.setData({
  49. collapsedStatus: !this.collapsedStatus
  50. });
  51. }
  52. },
  53. options: {
  54. multipleSlots: true
  55. },
  56. created: function () {}
  57. };
  58. </script>
  59. <style>
  60. /* components/agent-ui/collapsibleCard/index.wxss */
  61. </style>