How to use router after the simple introduction of vuejs and vue-routerjs?

clipboard.png

as shown in the figure, the directory structure is generally .html files, how to configure route redirection? Now the project is written in es5, seniors give me a comment or demo, thank you very much ^ _ ^

Jq
const router = new VueRouter({
  mode: "history",
  base: __dirname,
  routes: [
    { path: "/", component: Home },
    { path: "/foo", component: Foo },
    { path: "/bar", component: Bar }
  ]
})

if it is not a vue cli project

only vue.js single files are introduced

vue router is not recommended for route redirection

you can see those functions in the official documents

// 0. VueVueRouter Vue.use(VueRouter)

// 1.  () 
//  import 
const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }

// 2. 
//  "component" 
//  Vue.extend() 
// 
// 
const routes = [
  { path: '/foo', component: Foo },
  { path: '/bar', component: Bar }
]

pay attention to Foo Bar


vue-router is for single page applications
you are all html directly a tag jump or window.location.href jump on the line


Hello, have you solved your problem? Could you tell me about the solution, please?

Menu