Answer the question
In order to leave comments, you need to log in
How to strictly validate parameters in vue routing?
That is, it doesn't work for me:
props: {
id: Number.
}
Answer the question
In order to leave comments, you need to log in
Everything is written in the router dock: https://router.vuejs.org/en/guide/essentials/dynam...
vue-router uses path-to-regexp as an engine to check for route matches, allowing for many advanced features...
First: it's not at all clear how "strict" validation should look like in your opinion. Crash the app?
Second: this validation is in the component, not in the routing.
Third: any route input parameter is, by definition, a string, because is part of the string - url.
As a result: props
in the route properties it can be a function . In this function, you can add both your own validator and type casting.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question