D
D
Dauren S2020-06-04 06:04:47
Vue.js
Dauren S, 2020-06-04 06:04:47

Vue.js define route?

There is an address localhost:8080/editconsigment/1
activeUsers2(route)
{
if route === '/accounting/editconsigment/:id')
{
return true;
}
return false;
}
How to determine what is currently route ===/editconsigment/1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dauren S, 2020-06-04
@dauren101

<li class="list-group-item" :class="{ active: activeUsers($route.path,$route.params.id) }"> <router-link to="/accounting/consigment">Накладная</router-link></li>

methods:{
    activeUsers(route,id)
    {
      if(route === '/accounting/consigment' || route === '/accounting/editconsigment/'+id)
      {
        
        return true;
      }
      return false;
     
      
    },
   
 
 
  },

I
Ilya, 2020-06-04
@rpsv

Define by route name:

if (this.$route.name === 'route-name') {
  // code
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question