修改ThorUl中的tui-nomore组件样式

文章描述了tui-nomore组件在默认白色背景上遇到的问题,当页面背景色改变时,会出现视觉上的线状干扰。为解决这个问题,作者修改了组件的代码,增加了对背景色的控制,并调整了CSS样式,使用两条线来避免线条穿过的现象。
摘要由CSDN通过智能技术生成

tui-nomore组件背景色是固定的白色,当页面底色为其他颜色时,会变成以下效果

直接拉背景色变透明会变成这样,一条线穿过:

于是改用成两条线,修改tui-nomore组件代码如下(nomore.vue):

<template>
	<view class="tui-nomore-class tui-loadmore-none">
		<view :class="[isDot?'tui-nomore-dot':'tui-nomore']">
		</view>
		<view :class="[isDot?'tui-dot-text':'tui-nomore-text']">
			{{isDot?dotText:text}}
		</view>
		<view :class="[isDot?'tui-nomore-dot':'tui-nomore']">
		</view>
	</view>
</template>

<script>
	export default {
		name: "tuiNomore",
		props: {
			//当前页面背景颜色
			backgroundColor: {
				type: String,
				default: "#fafafa"
			},
			//是否以圆点代替 "没有更多了"
			isDot: {
				type: Boolean,
				default: false
			},
			//isDot为false时生效
			text: {
				type: String,
				default: "没有更多了"
			}
		},
		data() {
			return {
				dotText: "●"
			};
		}
	}
</script>

<style scoped>
	.tui-loadmore-none {
		width: 50%;
		margin: 1.5em auto;
		line-height: 1.5em;
		font-size: 24rpx;
		display: flex;
		justify-content: center;
	}

	.tui-nomore {
		width: 100%;
		height: 100%;
		position: relative;
		display: flex;
		justify-content: center;
		/* margin-top: 10rpx; */
		padding-bottom: 6rpx;
	}

	.tui-nomore::before {
		content: ' ';
		position: absolute;
		border-bottom: 1rpx solid #6d6d6d;
		-webkit-transform: scaleY(0.5);
		transform: scaleY(0.5);
		width: 100%;
		top: 18rpx;
		left: 0;
	}

	.tui-nomore-text {
		color: #999;
		font-size: 24rpx;
		text-align: center;
		padding: 0 18rpx;
		height: 36rpx;
		line-height: 36rpx;
		position: relative;
		z-index: 1;
		width: -webkit-fill-available;
		white-space: nowrap;
		background-color: #fff0 !important;
	}

	.tui-nomore-dot {
		position: relative;
		text-align: center;
		-webkit-display: flex;
		display: flex;
		-webkit-justify-content: center;
		justify-content: center;
		margin-top: 10rpx;
		padding-bottom: 6rpx;
	}

	.tui-nomore-dot::before {
		content: '';
		position: absolute;
		border-bottom: 1rpx solid #b4afaf;
		-webkit-transform: scaleY(0.5) translateX(-50%);
		transform: scaleY(0.5) translateX(-50%);
		width: 120rpx;
		top: 18rpx;
		left: 50%;
	}

	.tui-dot-text {
		position: relative;
		color: #e5e5e5;
		font-size: 10px;
		text-align: center;
		width: 50rpx;
		height: 36rpx;
		line-height: 36rpx;
		-webkit-transform: scale(0.8);
		transform: scale(0.8);
		-webkit-transform-origin: center center;
		transform-origin: center center;
		z-index: 1;
	}
</style>

修改之后的样式:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值