I tried to remove # in URL of my VueJS webapp, but even with
const router = createRouter({
mode: 'history',
history: createWebHashHistory(),
routes
})
# still appear. I'm pretty sure it's due to the createWebHashHistory function, but I can't remove it, or else, UI doesn't display.
So i tried another thing:
const router = createRouter({
history: true,
routes
})
but ui doesn't even display here.
The Vue.JS's official documentation doesn't help me on that point, could anyone help me there?
This worked for me:
const router = new VueRouter({
mode: 'history',
routes
})
So it is either history: createWebHashHistory(),
or the createRouter
.
This is my index.js
import { createRouter, createWebHistory } from "vue-router";
import Home from "../views/Home.vue";
import About from "../views/About.vue";
const routes = [
{
path: "/",
name: "Home",
component: Home,
},
{
path: "/about",
name: "About",
component: About,
},
];
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes,
});
export default router;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.