(fix) ページ遷移と連動する要素が動くようにした

close #12
This commit is contained in:
kakkokari-gtyih 2023-11-12 00:52:31 +09:00
parent 32b96c84e7
commit a9d0237a83
2 changed files with 10 additions and 16 deletions

View File

@ -63,13 +63,10 @@ const router = useRouter();
const route = useRoute();
const path = ref(route.path);
router.afterEach((to) => {
path.value = to.path;
});
onMounted(() => {
const _route = useRoute();
path.value = _route.path;
watch(() => route.path, (to) => {
path.value = to;
}, {
immediate: true,
});
const realLinks = findDeepObject(props.links[0], (v) => {

View File

@ -100,17 +100,14 @@ const props = withDefaults(defineProps<{
const navOpen = ref(false);
const { locales, locale: currentLocale } = useI18n();
const { path } = useRoute();
const route = useRoute();
const { afterEach, push } = useRouter();
const currentPath = ref(path);
const currentPath = ref(route.path);
afterEach((to) => {
currentPath.value = to.path;
});
onMounted(() => {
const _route = useRoute();
currentPath.value = _route.path;
watch(() => route.path,(to) => {
currentPath.value = to;
}, {
immediate: true,
});
const switchLocalePath = useSwitchLocalePath();