vue 除去#符号,并部署后浏览器刷新不出现404错误处理
export default new Router({mode:"history", //把模式改成history ,就可以去除 # 符号// base:'/', routes: [ { path: '/', name: 'HelloWorld', component: HelloWorld }, { path: '
·
export default new Router({
mode:"history", //把模式改成history ,就可以去除 # 符号
// base:'/',
routes: [
{
path: '/',
name: 'HelloWorld',
component: HelloWorld
},
{
path: '/firstpage',
name: 'firstpage',
component: firstpage
}
]
mode:"history", //把模式改成history ,就可以去除 # 符号
// base:'/',
routes: [
{
path: '/',
name: 'HelloWorld',
component: HelloWorld
},
{
path: '/firstpage',
name: 'firstpage',
component: firstpage
}
]
})
history模式后,部署刷新出现404错误问题,这个要在部署的后台进行配置,参考https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations
比如nginx下增加try_files $uri $uri/ /index.html;
location / {
root html;
index index.html index.htm;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
try_files $uri $uri/ /index.html;
}
更多推荐
已为社区贡献2条内容
所有评论(0)