How can I redirect localpath to another page with params Nuxt Js(如何将本地路径重定向到另一个带有params Nuxt Js的页面)
本文介绍了如何将本地路径重定向到另一个带有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的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:如何将本地路径重定向到另一个带有params Nuxt Js的页面


猜你喜欢
- 从原点悬停时触发 translateY() 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01