Jump to homepage as soon as refreshed
main.js
const router = new VueRouter({
history: false,
hashbang: true,
routes
})
router.js
const routers = [
{
path:'/login',
component:login,
},
{
path: '/welcome',
component: welcome,
},
{
path: '/test',
component: test,
},
{
path: '/',
component: Home,
children: [
{ path: '/clueFilter', component: clueFilter, name: '首页'},
{ path: '/myTags', component: myTags, name: '我的'},
]
},
{
path: '/',
component: Home,
children: [
{ path: '/statistics',component: statistics, name: '下载记录'},
{ path: '/tableHistory', component:tableHistory,name: '已下载'},
{ path: '', name: '业务分析',permissions:'vip'}
]
}
]
app.vue
export default {
name: 'app',
components: {
},
created: function () {
this.$router.push('/login')
}
}
No matter which page is refreshed, it always jumps to the login page. Is there something wrong with the way I set the initial page?
Read the official documentation carefully. . Use redirect to point to the homepage instead of pushing directly.
Try removing this code.
this.$router.push('/login')
Your app.vue is written like this in the created method. Once the app is created, it will jump to the /login page.
I don’t know what your business logic is, but the general idea is to make a judgment where you jump to /login, don’t jump directly.