The Vue-router documentation presents 2 specific usage patterns:
const route = useRoute();
// Obtain the current value
const id = route.params.id;
// Monitor for changes in the value
watch(
() => route.params.id,
(newValue, oldValue) => {
console.log(`The value changed from ${oldValue} to ${newValue}`);
});
Nevertheless, in many online examples, it is common to see the route being utilized as a computed
reactive property:
const id = computed(() => route.params.id);
I question the benefit of using computed
in this scenario.
It appears that this approach may not capture changes in value and adds unnecessary complexity in obtaining the value. Am I overlooking something?