一千位程序员,就有一千个不同的坑
首先大家不要气馁,就这个小犊子,浪费了我一个小时的时间才解决。
1.检查路由配置是否正确:
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/',
name: 'index',
// redirect:'about',
component: ()=>import('./views/Index.vue')
},
{
path: '/about',//注意这个开头是: /
//如果你忘掉了/,结果就是地址栏看起来跳转了,但是页面一片空白
name: 'about',
component: ()=>import('./views/About.vue')
}
]
})
2.检查你的根组件(App.vue)里面有没有写东西:
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
这里不能些其它的东西,写了的话这些东西将一直存在于你的页面中,挥之不去
3.检查你的router-link中写的对不对
<router-link to="about" tag="button">跳转到about页面</router-link>
<router-link :to="{ path: 'about', query: { plan: 'private' }}" tag="button">跳转到about页面</router-link>
网友评论