Vue-router Vue routing problems (pits)

Source: Internet
Author: User

Error in render function: "Typeerror:cannot Read property ' matched ' of undefined"


webpack4.0.1, there are also the following issues (note points):

1, Vuerouter instantiation of the parameters, can be abbreviated to routes, indicating routes:routes. Note, however, that "routes:routes" indicates that the property name is routes and the value is routes. In this case (both the property name and the value are routes), you can abbreviate it. However, do not mistakenly assume that the shorthand routes is the variable name (array name) of the route. If your array name is myroutes, then the correct notation is routes:myroutes.

The following is the correct example:

var myroutes= [
{path: "/", Component:hello},
{path: '/h ', Component:hello},
{path: "/w", Component:world}
];

Const Myroute = new Vuerouter ({

routes:myroutes

});

2, the official web, the instantiation of the Vue object, also used shorthand, such as:

Const APP = new Vue ({

Router

}). $mount (' #app ')

Router is equivalent to: Router:router, also because, like the variable name and the property name, if your route instance name is not router, do not omit it.

As follows:

Import {R} from "./router/index.js";//Routing configuration
The use function must be used for third-party components.
Vue.use (Vuerouter);

New Vue ({

El: "#app",
Router:r,
Render: (h) =>{
Return h (APP)
}
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.