Vue页面跳转,页面为空白的问题

记录一下页面跳转,页面为空白的问题,原本,我登录成功后想跳转到index首页的,然后我死命的点击它,它死活就是显示空白页面,后面发现需要在router文件夹中的index.js中配置其路由,而且注意,其路由不能写在调用父路由的上面,否则不生效,
话不多说直接上代码
index.js配置

import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import login from '../views/Login.vue'
import Index from '../views/index.vue'
Vue.use(VueRouter)

const routes = [
  
  {
    path: '/',
    name: 'Login',
    component: login
  },
  {
    path: '/',
    name: 'index',
    component: Index
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: function () {
      return import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
    }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router

代码中跳转的方式

this.$router.push({path:"/",name:"index"});
Logo

前往低代码交流专区

更多推荐