admin管理员组文章数量:1430083
In some situation, my logrocket always prompt me the the following error
Navigating to current location ("/error") is not allowed
However, when i check it in my web application. It works perfectly. I have no idea why logrocket always prompt this error in some of the user.
The following is my js code
gotoErrPage () {
this.$router.replace({
name: 'Error',
query: {
showRefresh: true,
},
})
},
In some situation, my logrocket always prompt me the the following error
Navigating to current location ("/error") is not allowed
However, when i check it in my web application. It works perfectly. I have no idea why logrocket always prompt this error in some of the user.
The following is my js code
gotoErrPage () {
this.$router.replace({
name: 'Error',
query: {
showRefresh: true,
},
})
},
Share
Improve this question
asked Sep 23, 2019 at 6:24
Chan Yoong HonChan Yoong Hon
1,8227 gold badges37 silver badges73 bronze badges
1
- would you show your router config? – Chiu Commented Sep 23, 2019 at 6:45
1 Answer
Reset to default 3Finally I understand why it happened. The error you see in the console is part of the new promise api: before, if no callbacks were supplied to router.push, errors were only sent to the global router error handler. Now, because both push and replace return a promise, if the navigation failure (anything that cancels a navigation like a next(false) or next('/other') also counts) is not caught, you will see an error in the console because that promise rejection is not caught. However, the failure was always there because trying to navigate to same location as the current one fails. It's now visible because of the promise being rejected but not caught.
I able to solve this issue with 2 solutions as following. The first solutions is using router-link.
<router-link
to="/Error"
v-slot="{ href, route, navigate, isActive, isExactActive }"
>
</router-link>
The second solutions is add catch in my function
this.$router.replace({
name: 'Error',
query: {
showRefresh: true,
}).catch(err => {})
本文标签: javascriptVuejs Navigating to current location (quotquot) is not allowedStack Overflow
版权声明:本文标题:javascript - [Vuejs ]Navigating to current location ("...") is not allowed - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745470582a2659729.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论