detailBlock.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. 这是一段需要展开收起的文字,可以有很多很多的字,可能会占据很多的空间。因此,在默认情况下,我们只会显示部分文字,而把其余的部分折叠起
  19. 来。如果需要查看全部内容,可以点击“查看更多按钮,文字内容就会展开显示了。
  20. </view>
  21. <!-- <text ref="p" class="p">
  22. 这是一段需要展开收起的文字,可以有很多很多的字,可能会占据很多的空间。因此,在默认情况下,我们只会显示部分文字,而把其余的部分折叠起
  23. 来。如果需要查看全部内容,可以点击“查看更多按钮,文字内容就会展开显示了。
  24. </text> -->
  25. <text class="btn-more" @click="qqq">
  26. {{isAll?'收起':'展开'}}
  27. </text>
  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. console.log(this.$refs.p.$el.classList);
  63. }else{
  64. this.$refs.p.$el.classList.remove('is-expanded')
  65. console.log(this.$refs.p.$el.classList);
  66. }
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss">
  72. .detailBlock{
  73. background-color: #ffffff;
  74. border-radius: 10rpx;
  75. padding: 15px 10px;
  76. .tit{
  77. font-weight: bold;
  78. margin-bottom: 10px;
  79. }
  80. .cont{
  81. color: #999999;
  82. margin-bottom: 10px;
  83. .content{
  84. // display: flex;
  85. // float: left;
  86. }
  87. .content .p{
  88. width: 90%;
  89. // max-width: 100%;
  90. // display:inline-block;
  91. // float: left;
  92. overflow:hidden;
  93. text-overflow:ellipsis;
  94. white-space:nowrap;
  95. // padding-right: 50rpx;
  96. /*设置文字溢出时显示省略号*/
  97. }
  98. .content .p.is-expanded{
  99. overflow:visible;
  100. white-space:normal;
  101. /*文字溢出时不再显示省略号*/
  102. }
  103. .btn-more{
  104. float: right;
  105. // width: 60px;
  106. transform: translate(0,-100%);
  107. color: #0056a8;
  108. }
  109. }
  110. }
  111. </style>