路由模式
History 模式以及 Hash 模式
// 网站根路径
https://yoursite.com/#/
// 某个路由
https://yoursite.com/#/user/idconst router = new VueRouter({
mode: 'history', // 路由模式
routes: [...]
})const routes = [
{
name: 'route1',
path: 'route1',
component: route1,
},
...
// 根据路由的优先级,前面的所有路由都不匹配的情况下,就会匹配 * 路由,返回 404 页面
{
name: 'not-found',
path: '*',
component: NotFound,
},
];Last updated