feat: 每次切换页面滚动条置顶
This commit is contained in:
parent
e65652fdc2
commit
f711a35651
@ -2,7 +2,7 @@
|
|||||||
import customHeader from "@/components/customHeader/index.vue";
|
import customHeader from "@/components/customHeader/index.vue";
|
||||||
import customFooter from "@/components/customFooter/index.vue";
|
import customFooter from "@/components/customFooter/index.vue";
|
||||||
import { NScrollbar } from "naive-ui";
|
import { NScrollbar } from "naive-ui";
|
||||||
import { computed } from "vue";
|
import { computed, watch, ref } from "vue";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -55,12 +55,18 @@ const currentBg = computed(() => {
|
|||||||
// 兜底:当作颜色或直接背景
|
// 兜底:当作颜色或直接背景
|
||||||
return { background: value };
|
return { background: value };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const scrollbarRef = ref(null);
|
||||||
|
watch(route, () => {
|
||||||
|
scrollbarRef.value?.scrollTo({ top: 0 });
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col h-screen">
|
<div class="flex flex-col h-screen">
|
||||||
<customHeader></customHeader>
|
<customHeader></customHeader>
|
||||||
<n-scrollbar
|
<n-scrollbar
|
||||||
|
ref="scrollbarRef"
|
||||||
class="bg-cover bg-center bg-no-repeat flex-1"
|
class="bg-cover bg-center bg-no-repeat flex-1"
|
||||||
style="background-size: 100% 100%; background-attachment: fixed"
|
style="background-size: 100% 100%; background-attachment: fixed"
|
||||||
:style="currentBg"
|
:style="currentBg"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user