How to access URL queries that have hyphen in them vue js

Viewed 445

I am trying to display a v-alert conditionally based on whether the payment-successful query parameter is true or false.

Here's what I tried:

<v-alert v-if="$route.query.payment-successful == true" type="success" dismissible>
  I'm an alert
</v-alert>

But it does not seem to work since the alert is not being displayed when I set the query param. I also tried putting the $route.query.payment-successful between quotes but it did not work either.

1 Answers

Try out to use [] squared brackets accessor :

<v-alert v-if="$route.query['payment-successful'] == true"></v-alert>
Related