Invalid vue default route

const routes = [
  {
    path:"/HelloWorld",
    component: HelloWorld
  },
  {
    path: "/second",
    component: second
  },
  //
  {
    path: "/",
    redirect: HelloWorld
  }
]

A second route is always displayed when it comes in. Click to switch, and set the default HelloWorld to make the initial route invalid. What"s the matter? (beginners of vue)

Mar.04,2021

you don't pay attention to the document. Your redirect is used improperly. There are usually two ways:

  • Redirect path
const routes = [
  {
    path:"/HelloWorld",
    component: HelloWorld
  },
  {
    path: "/second",
    component: second
  },
  //
  {
    path: '/',
    redirect: '/HelloWorld'
  }
]
  • Redirect name
const routes = [
  {
    path:"/HelloWorld",
    name: 'helloworld',
    component: HelloWorld
  },
  {
    path: "/second",
    component: second
  },
  //
  {
    path: '/',
    redirect: { name: 'helloworld' }
  }
]
< hr >

reference documentation: https://router.vuejs.org/zh-c.

I hope my answer will be helpful to you!
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34e6b-2b799.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34e6b-2b799.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?