What does mode mean in vue routing?

export function createRouter () {
  return new Router({
    mode: "history",
    scrollBehavior: () => ({ y: 0 }),
    routes
  })
}

didn"t you understand when you read the document? Test by yourself, after removing the mode root route, you will automatically add-sharp/
eg: http://localhost:8080/-sharp/ http://localhost:8080/-sharp/index
excuse me why this is and what this scrollBehavior means.


Don't use the framework without any basic knowledge, don't start with the framework without any basic knowledge, don't start with the framework without any basic knowledge.

suggest yourself Google: "front-end routing"


  1. ide/essentials/history-mode.html-sharp%E5%90%8E%E7%AB%AF%E9%85%8D%E7%BD%AE%E4%BE%8B%E5%AD%90" rel=" nofollow noreferrer "> HTML5 History mode , guess you should understand it, but the test is not correct. The history mode does not carry -sharp , and we don't know what went wrong in the current code.
  2. where do you want to navigate when switching routes

    const router = new VueRouter({
      routes: [...],
      scrollBehavior (to, from, savedPosition) {
        // return 
      }
    })

can be done directly with Baidu. Some of the documents are esoteric, which probably means that remove the-sharp after url and take the top of the page to the visible area


vur-router defaults to hash mode, so if you remove the mode:'history', route, you will use hash mode, so you will take-sharp;. If mode is set to history mode, the official website of
which uses history.pushState () to jump to url without refreshing the page is described in detail: ide/essentials/history-mode.html" rel=" nofollow noreferrer "> https://router.vuejs.org/zh/g.

.
Menu