美文网首页
路由相同路径报错问题解决

路由相同路径报错问题解决

作者: 一个健康马 | 来源:发表于2020-07-02 15:22 被阅读0次

//router.js加入
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}

//解决刷新页面404

export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes : routers
})

若后端将打包好的项目放在xxx.com/data/下,publicPath: '/data/',base使用publicPath的值,后端配置Nginx重定向到/data/index.html,增加404的路由,这样刷新页面停在当前页面,手动输入不存在的路由展示404.

相关文章

网友评论

      本文标题:路由相同路径报错问题解决

      本文链接:https://www.haomeiwen.com/subject/wmdrqktx.html