Vue路由首次跳转加载不出某个组件或显示空白,刷新一次才可显示(遇到的坑)

routes:[
    { path:'/home', component: Home, meta: { showFooter: true } },
    // 动态路由
    { path:'/search/:iptValue', component: Search,meta: { showFooter: true }, name: 'search' },
    { path:'/login', component: Login, meta: { showFooter: false } },
    { path:'/register', component: Register,meta: { showFooter: false } },
    { path: '/', redirect: '/home '}  //这个'前有个空格
  ]

删除home后的空格,改为 { path: '/', redirect: '/home'}就好了,所以写代码一定要严谨,规范,不然自己给自己挖坑找到头秃

你可能感兴趣的:(vue.js,javascript,前端)