[Vuejs]-Vue useRouter is "redundant" and dosnt works

0👍

You are trying to replace the query with itself

const old_query = useRoute().query;

const query = old_query;
delete query.postID;
replace({ query })
function replace({query}) {
  if (query === old_query) // true as you pass the same object you took from it
    throw new Error('Avoided redundant navigation to current location')
}

Use

// clone while dropping postID
const {postID, ...query} = useRoute().query;
useRouter().replace({ query })

Leave a comment