Open Fiouz opened 5 years ago
it's a different presentation but still the same information. Not sure what I will do here but I will see
RouteConfig
The type is the basic information that defines the route, and the configuration tells the program the view that needs to be obtained and the parameters passed, etc..
In the process of instantiating VueRouter, these configuration items are obtained through the createMatcher
=>createRouteMap
=>addRouteRecord
function to generate a tree of the RouteRecord
structure. It adds the upper and lower node information of each route configuration and the attributes hanging on the generated router-view instance. The specific code is as follows:
var record = {
path: normalizePath(path, parent),
components: route.components || { default: route.component },
instances: {},
name: name,
parent: parent,
matchAs: matchAs,
redirect: route.redirect,
beforeEnter: route.beforeEnter,
meta: route.meta || {}
}
So saying'Route records are the copies of the objects in the routes configuration Array (and in children Arrays)' is unreliable.
RouteConfig
is a static property type for configuring vueRouter
RouteRecord
is the tree node type when vueRouter is running
Version
3.0.2
Reproduction link
https://router.vuejs.org/api/
Steps to reproduce
routes
router construction options and see that theroutes
field is designated as an array ofRouteConfig
(with an accompanying definition of that type).$route.matched
and see that the copy of the aforementionedroutes
option is now designated as an array ofRouteRecord
(with not definition of that type)What is expected?
If the latter is a copy of the former, it should be expected that it should be the same object type or that an explicit relationship between the 2 types be mentioned in the API doc as a canonical definition.
What is actually happening?
There is no canonical definition of what a
RouteRecord
type is, we only have an example that denotes the array ofRouteConfig
and we don't understand why copying a type does not result of an instance of the same type.