Vue.js Nuxt.js中URL的哈希值

Vue.js Nuxt.js中URL的哈希值,vue.js,vue-router,nuxt.js,Vue.js,Vue Router,Nuxt.js,路由器模式是“历史记录”,我想在中间件中验证每个请求,当请求无效时,中间件会将请求重定向到给定页面。在我的情况下,white_路径中不存在的请求将重定向到“/500”: export default function (context) { const white_path = new Array('/login', '/404', '/500') const cur_path = context.route.path if(white_path.indexOf(cur_

路由器模式是“历史记录”,我想在中间件中验证每个请求,当请求无效时,中间件会将请求重定向到给定页面。在我的情况下,white_路径中不存在的请求将重定向到“/500”:

export default function (context) {
    const white_path = new Array('/login', '/404', '/500')
    const cur_path = context.route.path
    if(white_path.indexOf(cur_path) < 0){
        context.redirect(301, '/500')
    }
}
导出默认函数(上下文){
const white_path=新数组('/login','/404','/500')
const cur_path=context.route.path
if(白色路径索引of(当前路径)<0){
重定向(301,/500')
}
}
但问题是,当我输入url时:,但它会重定向到为什么散列值不消失?在中间件中,散列值为空,但重定向到客户端后,散列值成为最后一个url中出现的值


我怎样才能解决它?非常感谢您的支持

您是否尝试了
push
而不是
redirect
?@AdamOrlov否,但上下文没有函数push。我的解决方案并不完美:我在安装前清除window.location.hash。但是url更改时会有延迟。您是否尝试了
推送
而不是
重定向
?@AdamOrlov否,但上下文没有推送功能。我的解决方案并不完美:我在安装前清除window.location.hash。但url更改时会有延迟。