uniapp 中换行符号要在text中才生效

3,549 阅读1分钟

<template>
	<view class="dingdan-pay">
		<nav-bar showback>订单支付</nav-bar>
		<view class="w-100 mgt-32">
			<view class="dd-container ma0 d-flex">
				<view class="dd-left d-flex a-center j-center">
					<image src="../../static/images/pay/huangguan.png" class="pic-dd"></image>
				</view>
				<view class="dd-right">
					<view class="member-card">
						VIP会员卡
					</view>
					<view class="member-card-con">
						<text>{{chuliString}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				str:'• 会员有效期内可免费学习VIP课程 \n• 仅限本人使用,且购买成功即自动使用 \n• 多张VIP卡可自动叠加使用 '
			}
		},
		computed:{
			chuliString:function(){
			  // return 	 this.str
			  //  text 才支持  view 不支持
			  return 	 this.str.replace(/\n/g,"\n")
			}
		},
	}
</script>

<style lang="scss" scoped>
	.dd-container{
		
	width: 686rpx;
	height: 240rpx;
	background: linear-gradient(90deg, #EFCC77 0%, #F8E6AC 100%);
	border-radius: 16rpx;
	}
	.dd-left{
		flex: 1;
		height: 100%;
	}
	.dd-right{
		width: 462rpx;
		height: 100%;
	}
	.pic-dd{
		width: 128rpx;
		height: 128rpx;
	}
	.member-card{
		width: 100%;
		height: 56rpx;
		font-size: 28rpx;
		line-height: 56rpx;

	}
	.member-card-con{
		width: 428rpx;
		height: 120rpx;
		font-size: 24rpx;
		color: #8B572A;
		line-height: 40rpx;

	}
</style>