index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view class="collapse">
  3. <view class="header" @click="()=>{show = !show}">
  4. <view class="title">{{ title }}</view>
  5. <image :src="icon_arrow_up_black_16" v-if="show" />
  6. <image :src="icon_arrow_down_black_16" v-if="!show" />
  7. </view>
  8. <view class="content" v-if="show">
  9. <slot></slot>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'Collapse',
  16. props: {
  17. title: {
  18. type: String
  19. }
  20. },
  21. data() {
  22. return {
  23. icon_arrow_down_black_16: require('../tree-address/img/icon_arrow_down_black_16.svg'),
  24. icon_arrow_up_black_16: require('../tree-address/img/icon_arrow_up_black_16.svg'),
  25. show: true
  26. }
  27. }
  28. }
  29. </script>
  30. <style lang="scss" scoped>
  31. .collapse {
  32. background-color: rgba(255, 255, 255, 1);
  33. border-radius: 16rpx;
  34. padding: 16rpx;
  35. margin-top: 16rpx;
  36. .header {
  37. width: 100%;
  38. display: flex;
  39. align-items: center;
  40. justify-content: space-between;
  41. .title {
  42. color: rgba(20, 20, 20, 1);
  43. }
  44. uni-image {
  45. width: 32rpx;
  46. height: 32rpx;
  47. }
  48. }
  49. .content {
  50. padding: 24rpx 16rpx;
  51. // display: flex;
  52. // align-items: center;
  53. // justify-content: center;
  54. }
  55. }
  56. </style>