F
F
Farkl2022-02-15 14:52:45
Vue.js
Farkl, 2022-02-15 14:52:45

How to create a reactive variable that accepts route parameters?

When clicking, I pass parameters (videocards, processors)

@click="$router.push({name: 'adminVideo', params: {id: 'videocards'}})"
@click="$router.push({name: 'adminVideo', params: {id: 'processors'}})"


and accept them in the component

setup() {
    const route = useRoute()
    const path = computed(() => route.params.id)
    const routParam = path.value

  
    return { routParam}
  }


but the problem is that if I go to videocards first, routParam will become equal to videocards and after that if I go to processors, then routParam will not change, it will change only after the page is refreshed. How to make routeParam reactive?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Temur__k, 2022-02-15
@Temur__k

Try using :is in the component or keep-alive, I don't know if it will work or not.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question