如何访问其中包含连字符的 URL 查询 vue js

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

我正在尝试根据 payment-successful 查询参数是 true 还是 false.

有条件地显示 v-alert

这是我尝试过的:

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

但它似乎不起作用,因为当我设置查询参数时没有显示警报。我也尝试将 $route.query.payment-successful 放在引号之间,但它也不起作用。

尝试使用 [] 方括号访问器 :

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