fix: 個人資料修改後滾動至上方
This commit is contained in:
@@ -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 () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user