1👍
✅
use String.prototype.replaceAll() where appropriate to replace empty spaces with hyphens:
<router-link :to="`/blog/${blog?._title?.replaceAll(' ', '-')}`" />
You might also consider making the formatted string it’s own computed property if you need to perform the replacement more than once in your component.
0👍
you should add one more property like a slug in the blog object.
this.blog = { ...blog, slug: blog.title.replaceAll(' ','-').toLowerCase()}
now, you can use the slug in the router link.
<router-link :to="`/blog/${blog.slug}`"> ... </router-link>
Source:stackexchange.com