VUE 3 Router does not see GET parameters #2002
-
Reproductionhttps://app.ronbel.ru/poisk_korobok?length=200&width=100&height=100#/ Steps to reproduce the bugFollow the link Expected behaviorThe router gets get parameters Actual behaviorThe router is empty Additional information`<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script src="https://unpkg.com/vue-router@4/dist/vue-router.global.js"></script>const app = Vue.createApp({ // VueRouter app.use(router); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is because all navigations are async, you need to wait for the router to be ready: https://router.vuejs.org/guide/migration/#All-navigations-are-now-always-asynchronous async mounted() {
await this.$router.isReady()
this.$route.query.length
} In your case you should just use a computed instead of setting it in data: computed: {
length() {
return this.$route.query.length
}
} That way, the variable will update whenever it's ready |
Beta Was this translation helpful? Give feedback.
This is because all navigations are async, you need to wait for the router to be ready: https://router.vuejs.org/guide/migration/#All-navigations-are-now-always-asynchronous
In your case you should just use a computed instead of setting it in data:
That way, the variable will update whenever it's ready