detailBlock.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 class="btn-more" @click="qqq">
  22. {{isAll?'收起':'展开'}}
  23. </text>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name:"detailBlock",
  31. props:{
  32. item:{
  33. type:Object,
  34. default (){
  35. return{
  36. isshow:0 //0教研室 1 活动
  37. }
  38. }
  39. }
  40. },
  41. data() {
  42. return {
  43. isAll:false
  44. };
  45. },
  46. methods:{
  47. zdwz(){
  48. const query = wx.createSelectorQuery();
  49. query.select('#myElement').fields({ computedStyle: ['lineClamp'] }).exec((res) => {
  50. const element = res[0];
  51. element.style.webkitLineClamp = '4'; // 修改行数限制为 2
  52. });
  53. },
  54. qqq(){
  55. this.isAll=!this.isAll
  56. if(this.isAll){
  57. this.$refs.p.$el.classList.add('is-expanded')
  58. console.log(this.$refs.p.$el.classList);
  59. }else{
  60. this.$refs.p.$el.classList.remove('is-expanded')
  61. console.log(this.$refs.p.$el.classList);
  62. }
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. .detailBlock{
  69. background-color: #ffffff;
  70. border-radius: 10rpx;
  71. padding: 15px 10px;
  72. .tit{
  73. font-weight: bold;
  74. margin-bottom: 10px;
  75. }
  76. .cont{
  77. color: #999999;
  78. margin-bottom: 10px;
  79. .content{
  80. // display: flex;
  81. }
  82. .content .p{
  83. width: 90%;
  84. display:block;
  85. overflow:hidden;
  86. text-overflow:ellipsis;
  87. white-space:nowrap;
  88. // flex-grow: 1;
  89. // flex-wrap: wrap;
  90. // padding-right: 50rpx;
  91. /*设置文字溢出时显示省略号*/
  92. }
  93. .content .p.is-expanded{
  94. overflow:visible;
  95. white-space:normal;
  96. /*文字溢出时不再显示省略号*/
  97. }
  98. .activeTit{
  99. display: -webkit-box;
  100. word-break: break-all;
  101. text-overflow: ellipsis;
  102. overflow: hidden;
  103. -webkit-box-orient: vertical;
  104. -webkit-line-clamp:2;/*设置 需要显示的行数*/
  105. }
  106. .btn-more{
  107. float: right;
  108. transform: translate(0,-100%);
  109. color: #0056a8;
  110. }
  111. }
  112. }
  113. </style>