routing icon indicating copy to clipboard operation
routing copied to clipboard

How to use params with vue-i18n-routing?

Open bbauti opened this issue 11 months ago • 0 comments

Hi! I need to pass props to a route, but to do it I need to use the name of the route, and the library modifies it.

I tried to use localeLocation, and when running it inside a template it works correctly. My problem is that I need it to work inside the script block (I'm using vue3 with composition api, and the script setup syntax).

When using the function localeLocation inside the script, it tells me that it does not exist, when importing it (which I do not need to do when using it inside the template) and running the function it returns me that it cant find 'router', but I can not pass it to the function. What can I do to be able to use parameters with this library?

My project is configured like the playground vue3 project

<script setup lang="ts">
// Does not work
console.log(localeLocation({ name: 'about', params: { test: 'hola' } } ))
</script>

<template>
  <!-- Does work -->
  <pre>{{ localeLocation({ name: 'about', params: { test: 'hola' } }) }}</pre>
</template>

bbauti avatar Mar 19 '24 17:03 bbauti