首页 > 解决方案 > 在 vue-router 中重定向时如何从 VueJS 中的 URL 传递道具?

问题描述

我有在 4 秒内重定向用户的功能,但我需要以某种方式传递道具:

    setTimeout(() => {
      clearInterval(intervalId)
      this.$router.push({ path: `/${this.$store.state.locale}/my-cart` })
    }, 4000)

我试图做这样的事情:

this.$router.push({ name: '/${this.$store.state.locale}/my-cart', params: {step: '2'} })

这不起作用,这条路线在主页上重定向,那么,我该怎么做?

标签: vue.jsroutesvue-router

解决方案


this.$router.push({ path: '/${this.$store.state.locale}/my-cart', params: {step: '2' }})

请更改name并替换path为代码


推荐阅读