fix: 個人資料修改後滾動至上方

This commit is contained in:
skytek_xinliang
2026-08-31 14:37:27 +08:00
parent 403d6eaa0e
commit 7abe650757
+9 -1
View File
@@ -200,7 +200,7 @@
</template> </template>
<script setup lang="ts"> <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 Layout from "@/components/layout/DefaultLayout.vue";
import type { UserProfile } from "@/stores/app"; import type { UserProfile } from "@/stores/app";
import { useAppStore } from "@/stores/app"; import { useAppStore } from "@/stores/app";
@@ -305,6 +305,11 @@ function validateForm() {
return ""; return "";
} }
async function scrollToPageTop() {
await nextTick();
window.scrollTo({ top: 0 });
}
async function handleSubmit() { async function handleSubmit() {
errorMessage.value = ""; errorMessage.value = "";
successMessage.value = ""; successMessage.value = "";
@@ -312,6 +317,7 @@ async function handleSubmit() {
const validationError = validateForm(); const validationError = validateForm();
if (validationError) { if (validationError) {
errorMessage.value = validationError; errorMessage.value = validationError;
await scrollToPageTop();
return; return;
} }
@@ -338,6 +344,8 @@ async function handleSubmit() {
} finally { } finally {
saving.value = false; saving.value = false;
} }
await scrollToPageTop();
} }
onMounted(async () => { onMounted(async () => {