在新创建的vue项目中,在使用浏览器进行访问的时候,url 中总会出现# : http://localhost:8080/#/
如何去掉它,只需在路由配置js文件中,添加:mode: ‘history’,
export default new Router({
mode: 'history',
routes: [
{path: '/', name: 'HelloWorld', component: HelloWorld},
{path: '/pages01', name: 'pages01', component: pages01},
{path: '/pages02', name: 'pages02', component: pages02}
]
})
示例:
Vue目录结构