detailBlock.vue 3.5 KB

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