如何将本地路径重定向到另一个带有params Nuxt Js的页面 [英] How can I redirect localpath to another page with params Nuxt Js

查看:19
本文介绍了如何将本地路径重定向到另一个带有params Nuxt Js的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一些问题,我想将url中的参数推送到NuxtJs中的另一个页面

props: {
    idPending: {
      type: Number,
      required: true
    }
},

methods: {
    fetchpage() {
      const orderId = this.idPending;
      this.$router.push(
        this.localePath({
          name: 'Checkout-Confirmation-orderId', // page with params orderId
          params: { orderId: orderId }
        })
      );
    }
  }

当我这样做时,我出现此错误,我不明白为什么

Argument type {name: string, params: {orderId: Number}} is not assignable to parameter type RawLocation   Type Number is not assignable to type string 

请帮忙谢谢您

推荐答案

此错误实际上非常不言而喻,此处您只能使用String类型。
可在此处找到确认:https://github.com/vuejs/vue-router/issues/2895#issuecomment-523549070

您可以使用String(orderId),在我看来它可能更快,但主要是更安全,因为在orderId为NULL或未定义的情况下,它不会产生任何错误。

这篇关于如何将本地路径重定向到另一个带有params Nuxt Js的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆