uni-app中,固定宽高,文字超出部分,隐藏并显示省略号。


 

 


.topic_cont_text{ padding: 30upx; colof: #
999; background: #E1FFFF; max-height: 130upx; overflow: hidden; word-break: break-all; /* break-all(允许在单词内换行。) */ text-overflow: ellipsis; /* 超出部分省略号 */ display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/ -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/ -webkit-line-clamp: 2; /** 显示的行数 **/ }
<view class="topic_content">
    <view class="topic_cont_text">
        <template v-if="showText">
            {{topicDetail.description}}
            <text v-if="topicDetail.description !== null && topicDetail.description.length > 140" class="full_text" @click="toggleDescription">收起</text>
        </template>
        <template v-else>
            {{topicDetail.description.substr(0, 140)}}
            <text v-if="topicDetail.description !== null && topicDetail.description.length > 140" class="full_text" @click="toggleDescription">全文</text>
        </template>
    </view>
</view>

// 全文展开收起
toggleDescription (num) {
    this.showText = !this.showText
}, 

转载:https://blog.csdn.net/qq_41287423/article/details/98597276


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM