-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathSimpleView.vue
48 lines (44 loc) · 1.11 KB
/
SimpleView.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<script lang="ts" setup>
import { ref } from 'vue'
import { scrollWaiter } from './scrollWaiter'
defineProps<{ simple: boolean }>()
const viewName = ref('default')
function flushWaiter() {
scrollWaiter.flush()
}
function setupWaiter() {
scrollWaiter.add()
}
</script>
<template>
<RouterView v-if="simple" v-slot="{ Component, route }">
<component :is="Component" :key="route.meta.key" />
</RouterView>
<RouterView
v-else
:name="viewName"
v-slot="{ Component, route }"
key="not-simple"
>
<Transition
:name="route.meta.transition || 'fade'"
mode="out-in"
@before-enter="flushWaiter"
@before-leave="setupWaiter"
>
<!-- <KeepAlive> -->
<!-- <Suspense>
<template #default> -->
<!-- <div v-if="route.path.endsWith('/a')">A</div>
<div v-else>B</div> -->
<component
:is="Component"
:key="route.name === 'repeat' ? route.path : route.meta.key"
/>
<!-- </template>
<template #fallback> Loading... </template>
</Suspense> -->
<!-- </KeepAlive> -->
</Transition>
</RouterView>
</template>