去掉路由中的#号

vue开发时地址栏上的ip后面会跟着一个#号,如果想去掉这个井号,可以在路由上加上 mode: 'history',  就可以去掉

//设置路由
const router = new VueRouter({
    mode: "history",
    base: __dirname,
    routes: [
        { path: "/",component: Customers },
        { path: "/about",component: About },
        { path:"/add",component:Add },
        { path:"/customers/:id",component:CustomerDetails },
        { path:"/edit/:id",component:Edit }
    ]
})

 

posted @ 2023-02-22 16:50  罗砂  阅读(170)  评论(0)    收藏  举报