P粉8173547832023-07-28 15:48:22
The problem you are experiencing may be because Vue Router is trying to match based on the name of the route instead of the path.
You are trying to navigate to /consumers/1, expecting "1" to be a route parameter (:id). But Vue Router interprets "1" as the route name, hence the error message you see.
Make sure you navigate using the route path and not the route name. In your afterEach hook, use the following code:
router.afterEach((to, from) => { router.push(to.path); });
When navigating manually, use the path ('/consumers/1'), not the name. If you're still having problems, it's probably due to another part of your code.
The following is sample code for navigating to a route by name:
router.push({ name: 'Consumer Details', params: { id: 1 } })
Also, here is sample code for navigating to a route by path:
router.push('/consumers/1')
Should be useful