首先在route的配置文件中配置

变量前加:,这样就能传参给相应组件了

{
            path:'/user/:name',
            name:'user_info',
            component:UserInfo
        },

在相应组件中,写axios方法拿取数据

getUser(){
            Axios.get(`https://cnodejs.org/api/v1/user/${this.$route.params.name}`)
            .then(response=>{
                window.console.log(response)
            })
        }

注意:变量参数用的是`反单引号包裹

相关文章:

  • 2022-12-23
  • 2021-06-03
  • 2022-01-10
  • 2021-04-14
  • 2021-06-29
  • 2021-09-14
  • 2021-06-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案