fix: 個人資料修改後滾動至上方
This commit is contained in:
@@ -200,7 +200,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from "vue";
|
||||
import { computed, nextTick, onMounted, reactive, ref } from "vue";
|
||||
import Layout from "@/components/layout/DefaultLayout.vue";
|
||||
import type { UserProfile } from "@/stores/app";
|
||||
import { useAppStore } from "@/stores/app";
|
||||
@@ -305,6 +305,11 @@ function validateForm() {
|
||||
return "";
|
||||
}
|
||||
|
||||
async function scrollToPageTop() {
|
||||
await nextTick();
|
||||
window.scrollTo({ top: 0 });
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
errorMessage.value = "";
|
||||
successMessage.value = "";
|
||||
@@ -312,6 +317,7 @@ async function handleSubmit() {
|
||||
const validationError = validateForm();
|
||||
if (validationError) {
|
||||
errorMessage.value = validationError;
|
||||
await scrollToPageTop();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -338,6 +344,8 @@ async function handleSubmit() {
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
|
||||
await scrollToPageTop();
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
Reference in New Issue
Block a user