detailBlock.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="detailBlock">
  3. <view class="tit fwb-font" v-if="!item.isShow">教研室详情</view>
  4. <view class="tit fwb-font" v-else>活动详情</view>
  5. <view class="cont sZw-font">
  6. 会议时间:<text>10月7日上午八点(周日)</text>
  7. </view>
  8. <view class="cont sZw-font">
  9. 活动形式:<text style="color: #0056a8;">线上直播</text>
  10. </view>
  11. <view class="cont sZw-font">
  12. <!-- <view id="myElement" class="activeTit">
  13. 教研室概况:查看更多查看更多查看更多看更多查看更多查看更多查看更多查看更多查看更多查看更多查看更多看更多查看更多查看更多查看更多查看更多
  14. </view>
  15. <text class="zdwz" style="color: #0056a8;float: right;" @click="zdwz">收起</text> -->
  16. <view class="content">
  17. <view ref="p" :class="getClassNames">
  18. <text style="color: #999999;">教研室概况:</text>
  19. 这是一段需要展开收起的文字,可以有很多很多的字,可能会占据很多的空间。因此,在默认情况下,我们只会显示部分文字,而把其余的部分折叠起
  20. 来。如果需要查看全部内容,可以点击“查看更多按钮,文
  21. </view>
  22. <view ref="btnnn" :class="getClassNames1" @click="qqq">
  23. {{isAll ? '收起' : '展开'}}
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. name: "detailBlock",
  32. props: {
  33. item: {
  34. type: Object,
  35. default () {
  36. return {
  37. isshow: 0 //0教研室 1 活动
  38. }
  39. }
  40. }
  41. },
  42. data() {
  43. return {
  44. isAll: false
  45. };
  46. },
  47. computed: {
  48. getClassNames() {
  49. return {
  50. 'p': !this.isAll,
  51. 'is-expanded': this.isAll
  52. };
  53. },
  54. getClassNames1() {
  55. return {
  56. 'btn-more': !this.isAll,
  57. 'is-zd': this.isAll
  58. };
  59. }
  60. },
  61. methods: {
  62. // zdwz(){
  63. // const query = wx.createSelectorQuery();
  64. // query.select('#myElement').fields({ computedStyle: ['lineClamp'] }).exec((res) => {
  65. // const element = res[0];
  66. // element.style.webkitLineClamp = '4'; // 修改行数限制为 2
  67. // });
  68. // },
  69. qqq() {
  70. console.log(111);
  71. this.isAll = !this.isAll
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss">
  77. .detailBlock {
  78. background-color: #ffffff;
  79. border-radius: 10rpx;
  80. padding: 15px 10px;
  81. .tit {
  82. font-weight: 600;
  83. margin-bottom: 10px;
  84. }
  85. .cont {
  86. color: #999999;
  87. margin-bottom: 10px;
  88. text {
  89. color: #666666;
  90. }
  91. .content {
  92. // display: flex;
  93. // float: left;
  94. }
  95. .content .p {
  96. width: 90%;
  97. color: #666666;
  98. // max-width: 100%;
  99. // display:inline-block;
  100. display: block;
  101. // float: left;
  102. overflow: hidden;
  103. text-overflow: ellipsis;
  104. white-space: nowrap;
  105. // padding-right: 50rpx;
  106. /*设置文字溢出时显示省略号*/
  107. }
  108. .content .p.is-expanded {
  109. width: 100%;
  110. overflow: visible;
  111. white-space: normal;
  112. /*文字溢出时不再显示省略号*/
  113. }
  114. .btn-more {
  115. float: right;
  116. display: inline-block;
  117. // width: 60px;
  118. transform: translate(0, -100%);
  119. color: #0056a8;
  120. }
  121. .btn-more.is-zd {
  122. transform: none;
  123. // transform: translate(0,0);
  124. }
  125. }
  126. }
  127. </style>