I want to read all the query params from this page and pass them along to this
href
href
.
I tried something like
<script lang="ts">const {t} = useI18n();const route = useRoute();const query = route.query;const buttonUrl = computed(() => { // Get the base URL from translations const baseUrl = t('cta.button.url'); // Convert the route query parameters to a query string const queryString = new URLSearchParams(query).toString(); // Return the full URL, appending the query string if it exists return queryString ? `${baseUrl}?${queryString}` : baseUrl;});</script>
<script lang="ts">const {t} = useI18n();const route = useRoute();const query = route.query;const buttonUrl = computed(() => { // Get the base URL from translations const baseUrl = t('cta.button.url'); // Convert the route query parameters to a query string const queryString = new URLSearchParams(query).toString(); // Return the full URL, appending the query string if it exists return queryString ? `${baseUrl}?${queryString}` : baseUrl;});</script>
However, the
URLSearchParams
URLSearchParams
doesn't take a
LocationQuery
LocationQuery
(that is being return from
route.query
route.query
).
What's the best way to sort this out?
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community