3👍
✅
Query parameters in vue-router are always treated as string
. Because it can be page=1
like it could be page=foo
, there is no way to know.
So ?page=1
will be this.$route.query.page === "1"
To fix this, you’ll have to parse the parameter first:
const newPage = parseInt(this.$route.query.page, 10) + 1
Side note, assigning a new value to $router.query.page
doesn’t work. You have to push a new route for it to update:
const newPage = parseInt(this.$route.query.page, 10) + 1
this.$router.push({ query: newPage })
Source:stackexchange.com