javascript - vue refreshes and jumps to the home page
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-19 10:35:03
0
4
505

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?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(4)
某草草

Read the official documentation carefully. . Use redirect to point to the homepage instead of pushing directly.

大家讲道理

Try removing this code.
this.$router.push('/login')

Peter_Zhu

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.

仅有的幸福
 export default {
    name: 'app',
    components: {
    },
    created: function () {
      this.$router.push('/login') // 注意! 你这个代码的意思就是每次刷新的时候进入'/login',去掉就可以了
    }
 }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!