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

And*_*eth 2 vue.js vue-router vuetify.js

我试图v-alert根据payment-successful查询参数是true还是有条件地显示false.

这是我尝试过的:

<v-alert v-if="$route.query.payment-successful == true" type="success" dismissible>
  I'm an alert
</v-alert>
Run Code Online (Sandbox Code Playgroud)

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

Bou*_*him 5

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

<v-alert v-if="$route.query['payment-successful'] == true"></v-alert>
Run Code Online (Sandbox Code Playgroud)