Skip to content

How to use params with vue-i18n-routing? #89

@bbauti

Description

@bbauti

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions