Javascript Nuxt重定向双回问题
我对nuxt重定向有一个问题,在转到外部重定向并按“上一步”后,您将沿路由返回两次。我通过nuxt中间件处理重定向,有没有办法让路由器更新历史记录,或者更好的办法在vue/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
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"
}
]
以下是一个实时版本:
和代码: