gpt4 book ai didi

vue.js - 如何在 Nuxt 中重定向验证路由?

转载 作者:行者123 更新时间:2023-12-02 19:46:27 25 4
gpt4 key购买 nike

如果页面在验证其查询错误后我想重定向。我怎么能做到这一点?这是我的代码

validate({ params, query, router }){
if(isAfter(new Date(query.date_check_in), addDays(new Date(), 1)) !== true) {
query.date_check_in = format(addDays(new Date(), 1), 'YYYY-MM-DD')
query.date_check_out = format(addDays(new Date(), 2), 'YYYY-MM-DD')
return true
} else if(query.date_check_in === 'Invalid Date' || query.date_check_out === 'Invalid Date') {
router.push('search')
return true
}
}

最佳答案

你可以使用'重定向'

例如:

validate({ store, redirect }) {
// some codes...
redirect('/')
}

关于vue.js - 如何在 Nuxt 中重定向验证路由?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59168211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com