首页 > 解决方案 > Nuxt.js 中 URL 的哈希值

问题描述

路由器模式是“历史”,我想验证中间件中的每个请求,当请求无效时,它将请求重定向到给定页面。就我而言,white_path 中不存在的请求将被重定向到“/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')
    }
}

但问题是,当我输入网址时:http://localhost:3000/blog/SampleTitle/#first-paragraph,但随后它重定向到http://localhost:3000/500#first-paragraph为什么哈希值不会消失?在中间件中,hash 值为空,但是重定向到客户端后,hash 值变成了出现在最后一个 url 中的那个。

我该如何解决?非常感谢您!

标签: vue.jsvue-routernuxt.js

解决方案


推荐阅读