错误截图
踩坑原因
在配置vue-router的路由时和将router实例挂载至Vue实例上时,实例名称没有按照标准
配置vue时
在配置vue-router时,我们一般会将路由的映射关系抽成一个数组,就想下面这样
const routes = [{
path: '',
redirect: '/home'
},
{
path: '/home',
component: Home
},
{
path: '/category',
component: Category
},
{
path: '/shopcart',
component: ShopCart
},
{
path: '/profile',
component: Profile
}
];
然后再将这个路由映射数组添加至VueRouter对象中,然后导出,就像下面这样,在添加至VueRouter实例时,可以采用ES6的新写法,即直接写数组名routes
export default new VueRouter({
routes,
mode: '