VUE this.$router.push(‘/article‘) 报错问题

[Vue warn]: Error in v-on handler (Promise/async): "NavigationDuplicated: Navigating to current loca

问题:[Vue warn]: Error in v-on handler (Promise/async): “NavigationDuplicated: Navigating to current location (”/article") is not allowed"

红框为如今所处的路由地址。html

解决前是这样:this.$router.push({ path: ‘/commonSetting’ })vue

解决后:this.$router.push({ path: ‘/commonSetting’ },onComplete => {},
onAbort => {})

 注:就是在this.$router.push('/article') 加入onComplete => {},
onAbort => {}

原因:多次触发跳转就会有这个报错
意思详见Vue Router官网:https://router.vuejs.org/zh/guide/essentials/navigation.html

                                  OVER

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue中使用this.$router.push方法传递数组对象,可以使用以下方式: 1. 使用params传递参数: 在定义事件中,使用this.$router.push方法传递参数对象,在目标组件中使用this.$route.params接收参数。 例如:this.$router.push({name: 'Home', params: {user: 'david', items: [1, 2, 3}}); 在目标组件的created或mounted生命周期钩子中,使用this.$route.params接收参数。 例如:const items = this.$route.params.items; 2. 使用query传递参数: 在定义事件中,使用this.$router.push方法传递参数对象,在目标组件中使用this.$route.query接收参数。 例如:this.$router.push({path: '/home', query: {user: 'david', items: [1, 2, 3}}); 在目标组件的created或mounted生命周期钩子中,使用this.$route.query接收参数。 例如:const items = this.$route.query.items; 需要注意的是,通过query方式传递的数组对象会在地址栏中被强制转换成字符串,刷新页面后无法获取到正确的数组对象值。因此,推荐使用params方式传递数组对象。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [vue中this.$router.push()路由传值和获取的两种常见方法](https://blog.csdn.net/Vivien_CC/article/details/126880417)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值