Skip to content

watch router or router.currentRoute.path question #3867

@Miofly

Description

@Miofly

in App.vue

route change watch not trgger

watch(()=> router.currentRoute.path, (val) => {\
	console.log('router.currentRoute.path not trigger', val);
}, {
  immediate: true
});

why oldValue === val

watch(()=> route, (val, oldValue) => {
	console.log('route.path not trigger', val, oldValue);
  console.log('why is true', JSON.stringify(val) === JSON.stringify(oldValue));
}, {
  immediate: true,
  deep: true
});

home.vue

onDeactivated(() => {
  console.log('onDeactivated why after onBeforeRouteLeave');
})

onBeforeRouteLeave((_, from, next) => {
  console.log('onBeforeRouteLeave');
  next()
})

why onDeactivated after onBeforeRouteLeave

repo link: https://github.com/Miofly/demo-issue-template/tree/vue2-template

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions