Answer the question
In order to leave comments, you need to log in
How to fix incorrect display of slash in url (vue router)?
Good day I
ran into a problem, the essence is this:
A slug comes from the back, it is needed for a dynamic route
, here is the route
{
path: '/product/:slug/(.*)?',
name: 'Product',
params: true,
component: () => import(/* webpackChunkName: "Category" */ '../views/ProductCard')
},
url:"best-of-june/flowers/9150"
<router-link :to="{name:'Product', params: {slug: item.url }}</router-link>
http://sandbox/product/best-of-june%2Fflowers%2F9150
Answer the question
In order to leave comments, you need to log in
The router will escape everything params
except a special exception for *
.
If slug
you do not really need a separate one, then you can do this:
{
path: '/product/*',
name: 'Product',
params: true,
component: () => import(/* webpackChunkName: "Category" */ '../views/ProductCard')
},
<router-link :to="{name:'Product', params: {pathMatch: item.url}}</router-link>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question