解决进入页面无法到底部问题

This commit is contained in:
许允枞 2025-03-14 09:51:29 +08:00
parent 463f26d465
commit b977324bb7
2 changed files with 54 additions and 33 deletions

View File

@ -28,7 +28,8 @@
<view class="right_top"></view> <view class="right_top"></view>
</view> </view>
<!-- 聊天内容 --> <!-- 聊天内容 -->
<scroll-view class="chat" id="scrollview" scroll-y="true" scroll-with-animation="true" :scroll-into-view="scrollToView"> <scroll-view class="chat" id="scrollview" scroll-y="true" scroll-with-animation="true"
:scroll-into-view="scrollToView">
<view class="chat-main" :style="{paddingBottom:inputh+'px'}" id="msglistview"> <view class="chat-main" :style="{paddingBottom:inputh+'px'}" id="msglistview">
<view class="chat-ls" v-for="(item,index) in messagesList" :key="index" :id="'msg'+ index"> <view class="chat-ls" v-for="(item,index) in messagesList" :key="index" :id="'msg'+ index">
<view class="msg-m msg-right" v-if="item.isTrans"> <view class="msg-m msg-right" v-if="item.isTrans">
@ -494,7 +495,11 @@ export default {
} else { } else {
this.messagesList = tempList this.messagesList = tempList
} }
//
setTimeout(() => {
this.goBottom() this.goBottom()
}, 500);
// this.goBottom()
}, },
// //
getMessage() { getMessage() {
@ -528,7 +533,9 @@ export default {
that.$set(that.messagesList, that.messagesList.length - 1, that.messagesList[that.messagesList that.$set(that.messagesList, that.messagesList.length - 1, that.messagesList[that.messagesList
.length - 1]) .length - 1])
// Vue.js Vue.nextTick // Vue.js Vue.nextTick
setTimeout(() => {
that.goBottom() that.goBottom()
}, 500);
} }
get(); get();
@ -698,7 +705,6 @@ export default {
}, },
// //
goBottom() { goBottom() {
this.$nextTick(() => { this.$nextTick(() => {
this.scrollToView = this.scrollId; this.scrollToView = this.scrollId;
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -15,7 +15,7 @@
</view> </view>
</u-card> </u-card>
<u-form labelPosition="top" :model="form" ref="formRef" class=""> <u-form labelPosition="top" :rules="rules" :model="form" ref="formRef">
<u-form-item label="Name" prop="name" borderBottom> <u-form-item label="Name" prop="name" borderBottom>
<u-input v-model="form.name" placeholder="Enter your name" font-size="18"/> <u-input v-model="form.name" placeholder="Enter your name" font-size="18"/>
</u-form-item> </u-form-item>
@ -45,7 +45,26 @@ export default {
name: [ name: [
{ {
required: true, required: true,
message: '请输入姓名', message: 'Please enter your name',
trigger: ['blur', 'change']
}
],
email: [
{
required: true,
message: 'Please enter your email address',
trigger: ['blur', 'change']
},
{
pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
message: 'Please enter a valid email address',
trigger: ['blur', 'change']
}
],
message: [
{
required: true,
message: 'Please enter your feedback',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
} }
] ]
@ -55,21 +74,11 @@ export default {
methods: { methods: {
submitForm() { submitForm() {
this.$refs.formRef.validate().then(res => { this.$refs.formRef.validate().then(res => {
uni.$u.toast('校验通过')
}).catch(errors => {
uni.$u.toast('校验失败')
})
if (!this.form.name || !this.form.email || !this.form.message) {
uni.showToast({ title: 'Please fill in all fields', icon: 'none' });
return;
}
//
if (!this.form.email.match(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/)) {
uni.showToast({ title: 'Invalid email address', icon: 'none' });
return;
}
uni.showToast({title: 'Successfully', icon: 'success'}); uni.showToast({title: 'Successfully', icon: 'success'});
this.form = {name: '', email: '', message: ''}; this.form = {name: '', email: '', message: ''};
}).catch(errors => {
uni.$u.toast('Validation failed')
})
} }
} }
}; };
@ -86,6 +95,7 @@ export default {
font-size: 20rpx; font-size: 20rpx;
background-color: #FFFFFF; background-color: #FFFFFF;
} }
.card { .card {
width: 90%; width: 90%;
padding: 30rpx; padding: 30rpx;
@ -94,6 +104,7 @@ export default {
color: #FFFFFF; color: #FFFFFF;
border-radius: 20rpx; border-radius: 20rpx;
} }
.info { .info {
display: flex; display: flex;
align-items: center; align-items: center;
@ -101,11 +112,13 @@ export default {
margin-bottom: 20rpx; margin-bottom: 20rpx;
color: #FFFFFF; color: #FFFFFF;
} }
.info-text { .info-text {
margin-left: 15rpx; margin-left: 15rpx;
font-size: 22rpx; font-size: 22rpx;
color: #FFFFFF; color: #FFFFFF;
} }
.form-container { .form-container {
width: 90%; width: 90%;
//display: flex; //display: flex;
@ -113,12 +126,14 @@ export default {
align-items: center; align-items: center;
font-size: 22rpx; font-size: 22rpx;
} }
.button-container { .button-container {
display: flex; display: flex;
justify-content: center; justify-content: center;
width: 100%; width: 100%;
margin-top: 20rpx; margin-top: 20rpx;
} }
.submit-button { .submit-button {
font-size: 22rpx; font-size: 22rpx;
padding: 15rpx 30rpx; padding: 15rpx 30rpx;