[Vuejs]-Get the value for a query parameter re-actively

0👍

In your data you can make a route object and simply pass it to your :to property

<template>
  <div id="app">
    <div id="nav">
      <router-link :to="home_route">{{
        $t("home")
      }}</router-link>
      |
      <router-link to="/about">About</router-link>
    </div>
    <router-view />
  </div>
</template>

<script>
import i18n from "./i18n";

export default {
  data() {
    return {
      home_route : { name: 'HomeRoute', query: { lang: i18n.locale } }
    };
  },
</script>

Leave a comment