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?
某草草2017-05-19 10:37:03
Read the official documentation carefully. . Use redirect to point to the homepage instead of pushing directly.
天蓬老师2017-05-19 10:37:03
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.
仅有的幸福2017-05-19 10:37:03
export default {
name: 'app',
components: {
},
created: function () {
this.$router.push('/login') // 注意! 你这个代码的意思就是每次刷新的时候进入'/login',去掉就可以了
}
}