Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Nuxt重定向双回问题_Javascript_Vue.js_Nuxt.js - Fatal编程技术网

Javascript Nuxt重定向双回问题

Javascript Nuxt重定向双回问题,javascript,vue.js,nuxt.js,Javascript,Vue.js,Nuxt.js,我对nuxt重定向有一个问题,在转到外部重定向并按“上一步”后,您将沿路由返回两次。我通过nuxt中间件处理重定向,有没有办法让路由器更新历史记录,或者更好的办法在vue/nuxt中处理重定向 这是中间件重定向代码: export default function ({ route, redirect }) { // find the redirect if it exists where the from === the requested url var r = redir

我对nuxt重定向有一个问题,在转到外部重定向并按“上一步”后,您将沿路由返回两次。我通过nuxt中间件处理重定向,有没有办法让路由器更新历史记录,或者更好的办法在vue/nuxt中处理重定向

这是中间件重定向代码:


export default function ({ route, redirect }) {
    // find the redirect if it exists where the from === the requested url
    var r = redirects.find(r => r.from === route.fullPath)
    //If it exists, redirect the page with a 301 response else carry on
    if (r) {
        // console.log("Redirecting: {from: " + r.from + ", to: " + r.to + "}")
        return redirect(r.to)
    }
}
redirects.json

[
    {
        "from": "/google",
        "to": "https://www.google.com"
    }
]
以下是一个实时版本: 和代码: