关于 uniapp scroll-view聊天自动滚动到底部得

关于 uniapp scroll-view聊天自动滚动到底部得,第1张

需求:一般在scroll-view中会放置一个list列表,当列表条目增加的时候,使其自动滚动到底部显示最后一条
效果图下图:
刚开始进入的时候

这里自动撑开了

点击加号图标 恢复原来的样子

实现了聊天自动滚动到底部

这是最终效果图 其他的可以自己自行补全

全部代码都在这里了 包括样式 ,图片自己随便放上去就行了 希望帮住到大家 不喜勿喷
**

前提条件 uniapp uview-ui 必须引入 不然样式会出错

**


js部分





css 部分 因为之前整合过 所以 是有点乱的 不过都是全的 图片 都可以自己随便搞
page{
	background-color: #F6F7F9;
}
.indexTop{
	width: 100%;
	position: fixed;
	padding-top:10%;
	background-color: #ffffff;
	top: 0;
	z-index: 1;
	height: 270rpx;
	.location{
		position: absolute;
		margin-left: 3%;
		margin-top: 15rpx;
	
	}
	.navName{
		width: 100%;
		text-align: center;
		font-size: 36rpx;
		font-weight: bolder;
		.jobName{
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			text-align: left;
			color: #797a7f;
			text-align: center;
		}
	}
	.menu{
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #ffffff;
		padding-top: 16rpx;
		padding-bottom: 5rpx;
		.mentItem{
			text-align: center;
			img{
				width: 20px;
				height: 20px;
				object-fit: contain;
			}
			.mentItemTxt{
				font-size: 20rpx;
				font-family: PingFang SC, PingFang SC-Regular;
				font-weight: 400;
				color: #3d3d3d;
			}
		}
		.marginLeft124{
			margin-left: 17%;
		}
	}
}

.footer{
	width: 100%;
	position: fixed;
	bottom: 0;
	background-color: #ffffff;
	padding-top: 2%;
	padding-bottom: 2%;
	.caidan{
		width: 100%;
		
		display: flex;
		justify-content: center;
		align-items: center;
		.chang{
			img{
				width: 29px;
				height: 29px;
			}
		}
		.input{
			width: 60%;
		}
		.emoji{
			img{
				width: 29px;
				height: 29px;
			}
		}
		.jia{
			img{
				width: 29px;
				height: 29px;
			}
		}
	}
	.footerMenu{
		width: 100%;
		height: 328rpx;
	}
}

.scrollViewContent{
	width: 100%;
	.scrollview{
		width: 100%;
		.job{
			width: 94%;
			margin-left: 3%;
			background-color: #FFFFFF;
			border-radius: 20rpx;
			padding-top: 30rpx;
			padding-bottom: 30rpx;
			margin-top: 20rpx;
			.jobName{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding-left: 30rpx;
				padding-right: 30rpx;
				.position{
					font-size: 36rpx;
					font-weight: bold;
				}
				.price{
					font-size: 30rpx;
					font-weight: bold;
					color: #3C87F7;
				}
			}
			.tabs{
				width: 100%;
				display: flex;
				justify-content: left;
				flex-wrap: wrap;
				margin-top: 10rpx;
				padding-left: 30rpx;
				padding-right: 30rpx;
				.tab{
					padding: 10rpx 20rpx 10rpx 20rpx;
					background-color: #F6F7F9;
					border-radius: 10rpx;
					font-size: 24rpx;
					color: #3D3D3D;
					
					margin-top: 10rpx;
				}
				.margin-left{
					margin-left: 12rpx;
				}
				.tabRed{
					padding: 10rpx 20rpx 10rpx 20rpx;
					background-color: #FFF5F5;
					border-radius: 10rpx;
					font-size: 24rpx;
					color: #FF4747;
					margin-left: 12rpx;
					margin-top: 10rpx;
			
				}
			}
			.company{
				width: 100%;
				display: flex;
				margin-top: 30rpx;
				padding-left: 30rpx;
				padding-right: 30rpx;
				.companyName{
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC-Bold;
					font-weight: 700;
					color: #344363;
					display: flex;
					align-items: center;
					img{
						width: 29px;
						height: 29px;
						object-fit: contain;
						border-radius: 50%;
					}
					.name{
						margin-left: 23rpx;
					}
				}
				// .companyLoca{
				// 	font-size: 24rpx;
				// 	color: #B3B9C2;
				// 	padding-top: 20rpx;
				// }
			}
			
		}
		
		.content{
			width: 94%;
			background-color: #ffffff;
			margin-left: 3%;
			margin-top: 36rpx;
			padding-bottom: 36rpx;
			border-radius: 30rpx;
			padding-top: 49rpx;
			.jianliXz{
				img{
					width: 20px;
					height: 20px;
					object-fit: contain;
				}
			}
			.userInfo{
				width: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding-left: 50rpx;
				padding-right: 40rpx;
				.name{
					font-size: 42rpx;
					font-family: PingFang SC, PingFang SC-Bold;
					font-weight: 700;
					color: #1b1e27;
				}
				.job_zhiwei{
					margin-top: 11rpx;
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC-Regular;
					font-weight: 400;
					text-align: left;
					color: #797a7f;
				}
				.imgs{
					.sex{
						position: absolute;
						margin-top: 10rpx;
						margin-left: 100rpx;
						img{
							width: 16px;
							height: 16px;
							object-fit: contain;
						}
					}
					.userImg{
						img{
							width: 130rpx;
							height: 130rpx;
							object-fit: contain;
							border-radius: 50%;
						}
					}
					
				}
				
			}
			.lianxi{
				width: 100%;
				display: flex;
				justify-content: left;
				align-items: center;
				padding-left: 50rpx;
				padding-right: 40rpx;
				margin-top: 38rpx;
				.lianxiItem{
					display: flex;
					img{
						width: 18px;
						height: 18px;
					}
					.tiemTxt{
						margin-left: 5rpx;
						padding-top: 5rpx;
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC-Regular;
						font-weight: 400;
						color: #797a7f;
					}
				}
			}
		}
		.time{
			margin-top: 22rpx;
			padding-left: 30rpx;
			padding-right: 30rpx;
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			color: #b3b9c2;
			
		}
		
		.chattTime{
			margin-top: 33rpx;
			text-align: center;
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			color: #c7c7c7;
		}
		
		.users{
			width: 100%;
			.chater{
				width:100%;
				display: flex;
				justify-content: flex-end;
				margin-top: 40rpx;
				padding-right: 30rpx;
				.chaterImg{
					img{
						width: 39px;
						height: 39px;
						object-fit: contain;
						border-radius: 50%;
					}
				}
				.chaterMsg{
					width: 64%;
					display: flex;
					justify-content: flex-end;
					margin-right: 18rpx;
					.msgTxt{
						padding: 30rpx 12rpx 30rpx 22rpx;
						text-align: right;
						background-color: #3C87F7;
						border-top-left-radius: 20rpx;
						border-bottom-left-radius: 20rpx;
						border-bottom-right-radius: 20rpx;
						font-size: 32rpx;
						font-family: PingFang SC, PingFang SC-Regular;
						font-weight: 400;
						color: #ffffff;
					}
				}
				
			}
			.chatted{
				width:100%;
				display: flex;
				justify-content: flex-start;
				margin-top: 40rpx;
				padding-left: 30rpx;
				.chattedImg{
					img{
						width: 39px;
						height: 39px;
						object-fit: contain;
						border-radius: 50%;
					}
				}
				.chattedMsg{
					width: 64%;
					display: flex;
					justify-content: flex-start;
					margin-left: 18rpx;
					.msgTxt{
						padding: 30rpx 12rpx 30rpx 22rpx;
						text-align: left;
						background-color: #3C87F7;
						border-top-right-radius: 20rpx;
						border-bottom-left-radius: 20rpx;
						border-bottom-right-radius: 20rpx;
						font-size: 32rpx;
						font-family: PingFang SC, PingFang SC-Regular;
						font-weight: 400;
						color: #ffffff;
					}
				}
				
			}
		}
		
	}
}







欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1320375.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-11
下一篇 2022-06-11

发表评论

登录后才能评论

评论列表(0条)

保存