2๐
โ
You can use
<div v-if="this.$route.matched.some(route => route.path.includes('/projects'))">
etc.
</div>
includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate so www.example.com/projects/foo
and www.example.com/projects
return true
๐คctm
1๐
If I need to hide some div in one of the paths I am using this.$route.path
property.
<div v-if="this.$route.path === '/projects'">
Display only on views witch route is /projects
</div>
If you want to hide div in all paths which contains โ/projectsโ you can make it in this way.
<div v-if="this.$route.path.indexOf('/projects') >= 0">
Display only on views which contains /projects
</div>
๐คlaurisstepanovs
1๐
The best thing is to check on the name of the route
['route1', 'subroute1'].indexOf($route.name) >= 0
๐คybenhssaien
Source:stackexchange.com