Error in render function: "TypeError: Cannot read property 'matched' of undefined"
In webpack4.0.1, the following problems also exist (note points):
1. The parameters when VueRouter are instantiated can be abbreviated as routes, representing routes:routes. But it should be noted that "routes:routes" means that the attribute name is routes and the value is routes. In this case (the attribute name and value are routes), it can be abbreviated. However, don't mistakenly think that the abbreviated routes is the variable name (array name) of the route. If your array name is myroutes, then the correct way to write it is routes:myroutes.
Here is the correct example:
var myroutes= [
{path:"/",component:Hello},
{path:"/h",component:Hello},
{path:"/w",component:World}
];
const myroute = new VueRouter({
routes:myroutes
});
2. On the official website,When instantiating vue objects, abbreviations are also used, such as:
const app = new Vue({
router
}).$mount('#app')
router is equivalent to:router:router, also because variable names are the same as attribute names. If your router instance name is not a router, do not omit it.
as follows:
import {r} from "./router/";//Route configuration
//Use the use function.
(VueRouter);
new Vue({
el:"#app",
router:r,
render:(h)=>{
return h(App)
}
});