点击展开阅读全文--收起2版新增

 在项目中直接可以拿去用

<template>

			<!-- 点击展开阅读全文  -->
			<view class="xqnrbox" >
				<rich-text class="xqnr" :style="{display:xqnrdisplay}" :nodes="这是你的内容自行替换"></rich-text>
				<view class="xqnrname" @click="showdes()">
					<view class="text2">{{showdesname}}</view>
				</view>
			</view>

</template>

data(){
  return{
              showdesname: '阅读全文',
				xqnrdisplay: '-webkit-box',
				desseldisplay: '-webkit-box',
}
}
点击事件
// 点击阅读全文
			showdes() {
				if (this.xqnrdisplay == '-webkit-box') {
					this.showdesname = '收起';
					this.xqnrdisplay = 'block';
				} else if (this.xqnrdisplay == 'block') {
					this.showdesname = '阅读全文';
					this.xqnrdisplay = '-webkit-box';
				}
			},
css样式
.xqnrbox {
		position: relative;
		padding: 0 30upx;
	}

	.xqnr,
	.xqnr>p {
		color: #555450;
		font-size: 28upx;
		line-height: 2;
		margin: 40upx 0upx;
		/* display: -webkit-box; */
		overflow: hidden;
		text-overflow: ellipsis;
		word-wrap: break-word;
		white-space: normal !important;
		-webkit-line-clamp: 4;
		-webkit-box-orient: vertical;
	}

	.xqnrname {
		color: #555450;
		position: absolute;
		bottom: -40upx;
		right: 38upx;
		font-size: 28upx;
		// background-color: #fff;
		font-weight: 600;
		width: 132rpx;
		text-align: right;
	}

	.xqnrname .text2 {
		color: #34A3F2;
	}

第二版 :

<view class="xqnrbox" v-if="item.reminder">
		<view :class="{ 'expanded': expanded }" class="activity-list-remin">
            {{ item.reminder }}
         </view>
		<view class="read-more" @click="toggleExpanded">
             {{ expanded ? '收起' : '展开' }} 
        </view>
</view>
expanded: false, //在data中设置

//点击事件
 toggleExpanded() {
			    this.expanded = !this.expanded;
  },
//css 
	.activity-list-remin {
	  font-size: 24rpx;
	  font-family: PingFang SC, PingFang SC;
	  font-weight: 400;
	  color: #999999;
	  line-height: 160%;
	  text-indent: 2em;
	  margin-top: 12rpx;
	  overflow: hidden;
	  text-overflow: ellipsis;
	  word-wrap: break-word;
	  display: -webkit-box;
	  -webkit-line-clamp: 2; /* 默认显示两行 */ 更改这个 默认显示几行
	  -webkit-box-orient: vertical;
	}
	
	.expanded {
	  -webkit-line-clamp: initial; /* 显示所有内容 */
	  overflow: visible; /* 取消溢出隐藏 */
	}
	
	.read-more {
	  cursor: pointer;
	  color: blue;
	  text-align: right;
	}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值