当前位置:   article > 正文

uniapp开发微信小程序,多行文本换行,动态改变文字区域宽度_uniapp text宽度

uniapp text宽度

需求:商品标题部分超出两行显示… 且当点击编辑显示选择按钮后,文字区域宽度变小后,文字不能溢出。
如图:
在这里插入图片描述
在这里插入图片描述
HTML代码

<!-- 收藏 -->
<view class="goodsBox" v-if="type === 'favorite'" @tap="jump('/pageGoods/detail/index', { id: detail.id })">
	<view class="img">
		<image class="goodsImg" :src="detail.goods_image" mode=""></image>
	</view>
	<view class="goodsLeft">
		<view class="goodsLeftTitle f14 more-t" >
			{{ detail.goods_sku_text }}
		</view>
		<view class="collectionNum">{{ detail.collectionNum>10000?parseInt(detail.collectionNum/10000)+'万+':detail.collectionNum }}人收藏</view>
		<view style="display: flex;flex-flow: row nowrap;">
			<view class="price c1" style="font-size: 24rpx;" :style="detail.depreciate==0?'flex:1;':''">¥{{ detail.goods_price.toFixed(2) }}</view>
			<view style="flex: 1;" class="c1 f12 ml8" v-show="detail.depreciate"> 距加入降¥{{detail.depreciate}}</view>
			<view class="x-c"> <view class="box_label br16 bor c1 x-c f12">购买</view></view>
		</view>
	</view>
</view>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
.goodsBox {
	display: flex;
	.img {
		width: 170rpx;
		height: 170rpx;

		.goodsImg {
			width: 170rpx;
			height: 170rpx;
			border-radius: 10rpx;
			background-color: #ccc;
		}
	}
	.goodsLeft {
		flex: 1;
		margin-left: 10rpx;

		.goodsLeftTitle {
			overflow: hidden;
			text-overflow: ellipsis;
		}
		.f14 {
			font-size: 14px;
		}
		/*多行文本溢出省略号*/
		.more-t {
			overflow: hidden;// 超出的文本隐藏
			text-overflow: ellipsis;// 溢出用省略号显示
			display: -webkit-box;// 将对象作为弹性伸缩盒子模型显示。
			-webkit-line-clamp: 2;// 这个属性不是css的规范属性,需要组合上面两个属性,表示显示的行数。
			-webkit-box-orient: vertical;// 从上到下垂直排列子元素(设置伸缩盒子的子元素排列方式)
			transition: all linear 0.2s;
		}
		.collectionNum {
			margin: 10rpx 0;
			color: #a6a6a6;
			font-size: 24rpx;
		}
		.c1{
			color: rgba(255, 57, 51, 1) !important;
		}
		.f12 {
			font-size: 12px;
		}
		.ml8 {
			margin-left: 8px;
		}
		.bor{
			border: 1rpx solid rgba(255, 57, 51, 1);
		}
		.br16{
			border-radius: 32rpx;
		}
		.box_label{
			width: 106rpx;
			height: 40rpx;
		}
		/*上下左右居中*/
		.x-c {
			display: flex;
			justify-content: center;
			align-items: center;
		}
		.price {
			color: #e1212b;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 600;
		}
	}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/730024
推荐阅读
相关标签